本文整理汇总了PHP中Content::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Content::set方法的具体用法?PHP Content::set怎么用?PHP Content::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Content
的用法示例。
在下文中一共展示了Content::set方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveContent
/**
* コンテンツデータを登録する
* コンテンツデータを次のように作成して引き渡す
* 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;
}
示例2: array
$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();
示例3: Edition
* @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.
示例4: Content
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);
示例5: redirect
<?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);
}
}
}
示例6: Content
* 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>
示例7: Content
* 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;
示例8: Content
* 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">
示例9: isset
*/
// 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)) {
示例10: Content
* 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 . ' ' . $law->section_number . '</h1>');
$content->append('page_title', '<h2>' . $law->catch_line . '</h2>');
/*
* If we have Dublin Core metadata, display it.
*/
示例11: Content
* 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 = '';
示例12: Content
* 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.
示例13: Content
* @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();