本文整理汇总了PHP中Filter::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Filter::findAll方法的具体用法?PHP Filter::findAll怎么用?PHP Filter::findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filter
的用法示例。
在下文中一共展示了Filter::findAll方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
function edit($id)
{
if (!($snippet = Snippet::findById($id))) {
Flash::set('error', __('Snippet not found!'));
redirect(get_url('snippet'));
}
// check if trying to save
if (get_request_method() == 'POST') {
return $this->_edit($id);
}
$this->display('snippet/edit', array('action' => 'edit', 'filters' => Filter::findAll(), 'snippet' => $snippet));
}
示例2: _store
//.........这里部分代码省略.........
// Create the page object to be manipulated and populate data
if ($action == 'add') {
$page = new Page($data);
} else {
$page = Record::findByIdFrom('Page', $id);
$page->setFromData($data);
}
// Upon errors, rebuild original page and return to screen with errors
if (false !== $errors) {
$tags = $_POST['page_tag'];
// Rebuild time fields
if (isset($page->created_on)) {
$page->created_on = $page->created_on . ' ' . $page->created_on_time;
}
if (isset($page->published_on)) {
$page->published_on = $page->published_on . ' ' . $page->published_on_time;
}
if (isset($page->valid_until)) {
$page->valid_until = $page->valid_until . ' ' . $page->valid_until_time;
}
// Rebuild parts
$part = $_POST['part'];
if (!empty($part)) {
$tmp = false;
foreach ($part as $key => $val) {
$tmp[$key] = (object) $val;
}
$part = $tmp;
}
// Set the errors to be displayed.
Flash::setNow('error', implode('<br/>', $errors));
// display things ...
$this->setLayout('backend');
$this->display('page/edit', array('action' => $action, 'csrf_token' => SecureToken::generateToken(BASE_URL . 'page/' . $action), 'page' => (object) $page, 'tags' => $tags, 'filters' => Filter::findAll(), 'behaviors' => Behavior::findAll(), 'page_parts' => (object) $part, 'layouts' => Record::findAllFrom('Layout')));
}
// Notify
if ($action == 'add') {
Observer::notify('page_add_before_save', $page);
} else {
Observer::notify('page_edit_before_save', $page);
}
// Time to actually save the page
// @todo rebuild this so parts are already set before save?
// @todo determine lazy init impact
if ($page->save()) {
// Get data for parts of this page
$data_parts = $_POST['part'];
Flash::set('post_parts_data', (object) $data_parts);
if ($action == 'edit') {
$old_parts = PagePart::findByPageId($id);
// check if all old page part are passed in POST
// if not ... we need to delete it!
foreach ($old_parts as $old_part) {
$not_in = true;
foreach ($data_parts as $part_id => $data) {
$data['name'] = trim($data['name']);
if ($old_part->name == $data['name']) {
$not_in = false;
// this will not really create a new page part because
// the id of the part is passed in $data
$part = new PagePart($data);
$part->page_id = $id;
Observer::notify('part_edit_before_save', $part);
$part->save();
Observer::notify('part_edit_after_save', $part);
unset($data_parts[$part_id]);
示例3: __
?>
][filter_id]" onchange="setTextAreaToolbar('part_<?php
echo $index - 1;
?>
_content', this[this.selectedIndex].value)">
<option value=""<?php
if ($page_part->filter_id == '') {
echo ' selected="selected"';
}
?>
>— <?php
echo __('none');
?>
—</option>
<?php
foreach (Filter::findAll() as $filter) {
?>
<option value="<?php
echo $filter;
?>
"<?php
if ($page_part->filter_id == $filter) {
echo ' selected="selected"';
}
?>
><?php
echo Inflector::humanize($filter);
?>
</option>
<?php
示例4: edit
/**
* Saves the edited Snippet.
*
* @todo Merge _edit() and edit()
*
* @param string $id Snippet id.
*/
public function edit($id)
{
// check if user have already enter something
$snippet = Flash::get('post_data');
if (empty($snippet)) {
$snippet = Snippet::findById($id);
if (!$snippet) {
Flash::set('error', __('Snippet not found!'));
redirect(get_url('snippet'));
}
}
// check if trying to save
if (get_request_method() == 'POST') {
$this->_edit($id);
}
$this->display('snippet/edit', array('action' => 'edit', 'csrf_token' => SecureToken::generateToken(BASE_URL . 'snippet/edit'), 'filters' => Filter::findAll(), 'snippet' => $snippet));
}
示例5: _store
//.........这里部分代码省略.........
if (false !== $errors || $error_fields !== false) {
$tags = $_POST['page_tag'];
// Rebuild time fields
if (isset($page->created_on) && isset($page->created_on_time)) {
$page->created_on = $page->created_on . ' ' . $page->created_on_time;
}
if (isset($page->published_on) && isset($page->published_on_time)) {
$page->published_on = $page->published_on . ' ' . $page->published_on_time;
}
if (isset($page->valid_until)) {
$page->valid_until = $page->valid_until . ' ' . $page->valid_until_time;
}
// Rebuild parts
$part = '';
if (!empty($_POST['part'])) {
$part = $_POST['part'];
$tmp = false;
foreach ($part as $key => $val) {
$tmp[$key] = (object) $val;
}
$part = $tmp;
}
// Set the errors to be displayed.
$err_msg = $errors != false ? implode('<br/>', $errors) : '';
$err_msg .= $error_fields != false ? '<br />Please specify these fields: ' . implode(', ', $error_fields) : '';
Flash::setNow('error', $err_msg);
//$settingdata = 'aaa';
// display things ...
$this->setLayout('backend');
$pagesettingobj = new stdClass();
foreach ($pagesetting as $name => $value) {
$pagesettingobj->{$name} = $value;
}
$this->display('page/edit', array('action' => $action, 'csrf_token' => SecureToken::generateToken(BASE_URL . 'page/' . $action), 'page' => (object) $page, 'pagesetting' => $pagesettingobj, 'tags' => $tags, 'filters' => Filter::findAll(), 'behaviors' => Behavior::findAll(), 'page_parts' => $part, 'layouts' => Record::findAllFrom('Layout')));
}
// Notify
if ($action == 'add') {
Observer::notify('page_add_before_save', $page);
} else {
Observer::notify('page_edit_before_save', $page);
}
// Time to actually save the page
// @todo rebuild this so parts are already set before save?
// @todo determine lazy init impact
$page->newwindow = !empty($data['newwindow']) ? '1' : '0';
if ($page->save()) {
// Get data for parts of this page
$data_parts = $_POST['part'];
Flash::set('post_parts_data', (object) $data_parts);
if ($action == 'edit') {
$old_parts = PagePart::findByPageId($id);
// check if all old page part are passed in POST
// if not ... we need to delete it!
foreach ($old_parts as $old_part) {
$not_in = true;
foreach ($data_parts as $part_id => $data) {
$data['name'] = trim($data['name']);
if ($old_part->name == $data['name']) {
$not_in = false;
// this will not really create a new page part because
// the id of the part is passed in $data
$part = new PagePart($data);
$part->page_id = $id;
Observer::notify('part_edit_before_save', $part);
$part->save();
Observer::notify('part_edit_after_save', $part);
示例6: edit
public function edit($id = null)
{
if (is_null($id)) {
redirect(get_url('page'));
}
$page = Page::findById($id);
if (!$page) {
Flash::set('error', __('Page not found!'));
redirect(get_url('page'));
}
// check for protected page and editor user
if (!AuthUser::hasPermission('administrator') && !AuthUser::hasPermission('developer') && $page->is_protected) {
Flash::set('error', __('You do not have permission to access the requested page!'));
redirect(get_url('page'));
}
// check if trying to save
if (get_request_method() == 'POST') {
return $this->_edit($id);
}
// find all page_part of this pages
$page_parts = PagePart::findByPageId($id);
if (empty($page_parts)) {
$page_parts = array(new PagePart());
}
$tag_array = array();
foreach ($page->tags() as $tag) {
$tag_array[] = $tag->name();
}
// display things ...
$this->setLayout('backend');
$this->display('page/edit', array('action' => 'edit', 'page' => $page, 'tags' => $tag_array, 'filters' => Filter::findAll(), 'behaviors' => Behavior::findAll(), 'page_parts' => $page_parts, 'layouts' => Layout::find(array('order' => 'position'))));
}