Exemplo n.º 1
0
 /**
  * コンテンツデータを登録する
  * コンテンツデータを次のように作成して引き渡す
  * array('Content' =>
  * 			array(	'model_id'	=> 'モデルでのID'
  * 					'category'	=> 'カテゴリ名',
  * 					'title'		=> 'コンテンツタイトル',		// 検索対象
  * 					'detail'	=> 'コンテンツ内容',		// 検索対象
  * 					'url'		=> 'URL',
  * 					'status' => '公開ステータス'
  * ))
  *
  * @param Model $model
  * @param array $data
  * @return boolean
  * @access public
  */
 public function saveContent(Model $model, $data)
 {
     if (!$data) {
         return;
     }
     $data['Content']['model'] = $model->alias;
     // タグ、空白を除外
     $data['Content']['detail'] = str_replace(array("\r\n", "\r", "\n", "\t", "\\s"), '', trim(strip_tags($data['Content']['detail'])));
     // 検索用データとして保存
     $id = '';
     $this->Content = ClassRegistry::init('Content');
     if (!empty($data['Content']['model_id'])) {
         $before = $this->Content->find('first', array('fields' => array('Content.id', 'Content.category'), 'conditions' => array('Content.model' => $data['Content']['model'], 'Content.model_id' => $data['Content']['model_id'])));
     }
     if ($before) {
         $data['Content']['id'] = $before['Content']['id'];
         $this->Content->set($data);
     } else {
         if (empty($data['Content']['priority'])) {
             $data['Content']['priority'] = '0.5';
         }
         $this->Content->create($data);
     }
     $result = $this->Content->save();
     // カテゴリを site_configsに保存
     if ($result) {
         return $this->updateContentMeta($model, $data['Content']['category']);
     }
     return $result;
 }
Exemplo n.º 2
0
$contents = $Content->find('all', array('cache' => false));
if ($contents) {
    foreach ($contents as $content) {
        $content['Content']['priority'] = '0.5';
        switch ($content['Content']['model']) {
            case 'Page':
                $type = 'ページ';
                break;
            case 'BlogPost':
                $type = 'ブログ';
                break;
            default:
                $type = '';
        }
        $content['Content']['type'] = $type;
        $Content->set($content);
        if (!$Content->save()) {
            $result = false;
        }
    }
    if ($result) {
        $this->setMessage('contents テーブルのデータ更新に成功しました。');
    } else {
        $this->setMessage('contents テーブルのデータ更新に失敗しました。', true);
    }
}
/**
 * page_categories データ更新
 */
App::import('Model', 'PageCategory');
$PageCategory = new PageCategory();
Exemplo n.º 3
0
 * @version		0.9
 * @link		http://www.statedecoded.com/
 * @since		0.1
*/
/*
 * Setup the edition object.
 */
require_once INCLUDE_PATH . 'class.Edition.inc.php';
global $db;
$edition_obj = new Edition(array('db' => $db));
$permalink_obj = new Permalink(array('db' => $db));
/*
 * Create a container for our content.
 */
$content = new Content();
$content->set('browser_title', 'Editions');
$content->set('page_title', '<h2>Editions</h2>');
/*
 * Get editions.
 */
$editions = $edition_obj->all();
$body = '<p>
	These are the available editions of the code.
</p>';
$body .= '<ol class="edition-list">';
foreach ($editions as $edition) {
    // If we have a passed url, use it.
    if ($_GET['from']) {
        $from_permalink = $permalink_obj->translate_permalink($_GET['from'], $edition->id);
    }
    // Translate our url into a shiny new permalink.
Exemplo n.º 4
0
    ob_end_clean();
}
/*
 * If this is an AJAX request
 */
if (isset($_GET['noframe'])) {
    echo $body;
} else {
    /*
     * Create a container for our content.
     */
    $content = new Content();
    /*
     * Define some page elements.
     */
    $content->set('browser_title', 'Admin');
    $content->set('body_class', 'inside');
    /*
     * Put the shorthand $body variable into its proper place.
     */
    $content->set('body', '<div class="nest narrow">');
    $content->append('body', '<h1>Admin</h1>');
    $content->append('body', $body);
    $content->append('body', '</div>');
    unset($body);
    /*
     * Parse the template, which is a shortcut for a few steps that culminate in sending the content
     * to the browser.
     */
    $template = Template::create('admin');
    $template->parse($content);
Exemplo n.º 5
0
<?php

if (!isset($_SESSION['debugmode'])) {
    $_SESSION['debugmode'] = false;
}
if ($slug == "debugmode") {
    if (!isset($params[0])) {
        Content::set("Your current debug mode state is: " . ($_SESSION['debugmode'] ? 'ON' : 'OFF'));
        Content::append("<form action='/debugmode/" . (!$_SESSION['debugmode'] ? 'on' : 'off') . "'><input type='submit' value='Click to toggle' /></form>");
    } else {
        if ($params[0] == 'on') {
            $_SESSION['debugmode'] = true;
            redirect('/debugmode', true);
        } else {
            $_SESSION['debugmode'] = false;
            redirect('/debugmode', true);
        }
    }
}
Exemplo n.º 6
0
 * PHP version 5
 *
 * @license		http://www.gnu.org/licenses/gpl.html GPL 3
 * @version		0.9
 * @link		http://www.statedecoded.com/
 * @since		0.1
 *
 */
/*
 * Create a container for our content.
 */
$content = new Content();
/*
 * Define some page elements.
 */
$content->set('browser_title', '404, Not Found');
$content->set('page_title', '404, Not Found');
/*
 * Send a 404 header to the browser.
 */
header('HTTP/1.1 404 Not Found');
$body = '
<p>The page that you’re looking for is nowhere to be found. Sorry! Here are a few potential
solutions to the problem:</p>

<ul>
	<li>Check the website address at the top of your browser. Do you see any obvious errors?
	Fix ‘em!</li>
	<li>Try using the search box, at the top of the page, to search for what you’re looking for.</li>
	<li>Start over again <a href="/">at the home page</a> and try to browse your way to what you’re
	trying to find.</li>
Exemplo n.º 7
0
 * PHP version 5
 *
 * @license		http://www.gnu.org/licenses/gpl.html GPL 3
 * @version		0.9
 * @link		http://www.statedecoded.com/
 * @since		0.8
 *
 */
/*
 * Create a container for our content.
 */
$content = new Content();
/*
 * Define some page elements.
 */
$content->set('browser_title', 'Downloads');
$content->set('page_title', 'Downloads');
/*
 * Provide some custom CSS for this form.
 */
$content->set('inline_css', '<style>
		#required-note {
			font-size: .85em;
			margin-top: 2em;
		}
		.required {
			color: #f00;
		}
		#api-registration label {
			display: block;
			margin-top: 1em;
Exemplo n.º 8
0
 * PHP version 5
 *
 * @license		http://www.gnu.org/licenses/gpl.html GPL 3
 * @version		0.8
 * @link		http://www.statedecoded.com/
 * @since		0.8
 *
 */
/*
 * Fire up our templating engine.
 */
$content = new Content();
/*
 * Define some page elements.
 */
$content->set('browser_title', '');
$content->set('page_title', '');
$content->set('body', '<!-- UNCOMMENT TO DISPLAY AN INTRODUCTORY VIDEO HERE
	<div class="nest video">
		<div class="video-frame">
			<div class="video-container">
				<video width="" height="" controls="controls">
					<source src="" type="video/mp4">
					<source src="" type="video/webm">
				</video>
			</div>
		</div>
	</div>--> <!-- // .nest -->

	<section class="homepage" role="main">
		<div class="nest">
Exemplo n.º 9
0
 */
// Again, if we at the top level, this will return null
$structure = isset($struct->structure) ? $struct->structure : '';
/*
 * Get a listing of all the structural children of this portion of the structure.
 */
$children = $struct->list_children();
/*
 * Create a container for our content.
 */
$content = new Content();
/*
 * Define the title page elements.
 */
if (strlen($structure_id) > 0) {
    $content->set('browser_title', $struct->name);
    $content->set('page_title', '<h2>' . $struct->name . '</h2>');
} else {
    $content->set('browser_title', SITE_TITLE . ': The ' . LAWS_NAME . ', for Humans.');
}
/*
 * Make some section information available globally to JavaScript.
 */
$content->append('javascript', "var api_key = '" . API_KEY . "';");
/*
 * Define the breadcrumb trail.
 */
if (count((array) $structure) > 1) {
    foreach ($structure as $level) {
        $active = '';
        if ($level == end($structure)) {
Exemplo n.º 10
0
     * Send the text, which is already formatted properly.
     */
    echo $law->plain_text;
    /*
     * End processing and exit.
     */
    exit;
}
/*
 * Create a container for our content.
 */
$content = new Content();
/*
 * Make some section information available globally to JavaScript.
 */
$content->set('javascript', "var section_number = '" . $law->section_number . "';");
$content->append('javascript', "var law_id = '" . $law->law_id . "';");
$content->append('javascript', "var edition_id = '" . $law->edition_id . "';");
$content->append('javascript', "var api_key = '" . API_KEY . "';");
/*
 * Define the browser title.
 */
$content->set('browser_title', $law->catch_line . ' (' . SECTION_SYMBOL . ' ' . $law->section_number . ')—' . SITE_TITLE);
/*
 * Define the page title.
 */
$content->set('page_title', '<h1>' . SECTION_SYMBOL . '&nbsp;' . $law->section_number . '</h1>');
$content->append('page_title', '<h2>' . $law->catch_line . '</h2>');
/*
 * If we have Dublin Core metadata, display it.
 */
Exemplo n.º 11
0
 * Get a listing of all the structural children of this portion of the structure.
 */
$children = $struct->list_children();
/*
 * Create a container for our content.
 */
$content = new Content();
/*
 * Setup the body.
 */
$body = '';
/*
 * Define the title page elements.
 */
if (strlen($structure_id) > 0) {
    $content->set('browser_title', $struct->name);
    $content->set('page_title', '<h2>' . $struct->name . '</h2>');
} else {
    $content->set('browser_title', SITE_TITLE . ': The ' . LAWS_NAME . ', for Humans.');
    $content->set('page_title', '<h2>' . ucwords($children->{0}->label) . 's of the ' . LAWS_NAME . '</h2>');
}
/*
 * Make some section information available globally to JavaScript.
 */
$content->append('javascript', "var api_key = '" . API_KEY . "';");
/*
 * Define the breadcrumb trail.
 */
if (count((array) $structure) > 1) {
    foreach ($structure as $level) {
        $active = '';
Exemplo n.º 12
0
 * PHP version 5
 *
 * @license		http://www.gnu.org/licenses/gpl.html GPL 3
 * @version		0.8
 * @link		http://www.statedecoded.com/
 * @since		0.1
 *
 */
/*
 * Create a container for our content.
 */
$content = new Content();
/*
 * Define some page elements.
 */
$content->set('browser_title', 'About');
$content->set('page_title', 'About');
$body = '';
$sidebar = '';
/*
 * Put the shorthand $body variable into its proper place.
 */
$content->set('body', $body);
unset($body);
/*
 * Put the shorthand $sidebar variable into its proper place.
 */
$content->set('sidebar', $sidebar);
unset($sidebar);
/*
 * Add the custom classes to the body.
Exemplo n.º 13
0
 * @link		http://www.statedecoded.com/
 * @since		0.8
 *
 */
/*
 * Intialize Solarium and instruct it to use the correct request handler.
 */
$client = new Solarium_Client($GLOBALS['solr_config']);
/*
 * Create a container for our content.
 */
$content = new Content();
/*
 * Define some page elements.
 */
$content->set('browser_title', 'Search');
$content->set('page_title', 'Search');
/*
 * Initialize our two primary content variables.
 */
$body = '';
$sidebar = '';
/*
 * Set our API key as a JavaScript variable, to be used by our autocomplete JavaScript.
 */
$content->set('javascript', "var api_key = '" . API_KEY . "';");
/*
 * Create a new instance of our search class. We use this to display the search form and the result
 * page numbers.
 */
$search = new Search();