本文整理汇总了PHP中Record::findAllFrom方法的典型用法代码示例。如果您正苦于以下问题:PHP Record::findAllFrom方法的具体用法?PHP Record::findAllFrom怎么用?PHP Record::findAllFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record::findAllFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
public function add($parent_id = 1)
{
// check if trying to save
if (get_request_method() == 'POST') {
return $this->_add();
}
$data = Flash::get('post_data');
$page = new Page($data);
$page->parent_id = $parent_id;
$page->status_id = Setting::get('default_status_id');
$page_parts = Flash::get('post_parts_data');
if (empty($page_parts)) {
// check if we have a big sister ...
$big_sister = Page::findBigSister($parent_id);
if ($big_sister) {
// get all is part and create the same for the new little sister
$big_sister_parts = Record::findAllFrom('PagePart', 'page_id=? ORDER BY id', array($big_sister->id));
$page_parts = array();
foreach ($big_sister_parts as $parts) {
$page_parts[] = new PagePart(array('name' => $parts->name, 'filter_id' => Setting::get('default_filter_id')));
}
} else {
$page_parts = array(new PagePart(array('filter_id' => Setting::get('default_filter_id'))));
}
}
// display things ...
$this->setLayout('backend');
$this->display('page/edit', array('action' => 'add', 'page' => $page, 'tags' => array(), 'filters' => Filter::findAll(), 'behaviors' => Behavior::findAll(), 'page_parts' => $page_parts, 'layouts' => Layout::find()));
}
示例2: index
function index()
{
// load redirects and logged 404 errors
$data['current_redirects'] = Record::findAllFrom('RedirectorRedirects', 'true ORDER BY destination, url');
$data['current_404s'] = Record::findAllFrom('Redirector404s', 'true ORDER BY hits DESC');
$this->display('redirector/views/index', $data);
}
示例3: clear
function clear()
{
$log_entry = Record::findAllFrom('DashboardLogEntry');
foreach ($log_entry as $entry) {
$entry->delete();
}
redirect(get_url('plugin/dashboard/'));
}
示例4: findAll
public static function findAll($limit = null)
{
$where = 'AND count > 0';
if (isset($limit)) {
$where .= " order by count desc LIMIT {$limit} ";
}
return Record::findAllFrom('Tag', $where);
}
示例5: redirector_log_404
function redirector_log_404()
{
$redirect = Record::findAllFrom('Redirector404s', 'url = \'' . $_SERVER['REQUEST_URI'] . '\'');
if (sizeof($redirect) > 0) {
Record::update('Redirector404s', array('hits' => $redirect[0]->hits + 1), 'id = ' . $redirect[0]->id);
} else {
Record::insert('Redirector404s', array('url' => $_SERVER['REQUEST_URI']));
}
}
示例6: init
public static function init()
{
$settings = Record::findAllFrom('PageSetting');
$pagesetting = new stdClass();
foreach ($settings as $setting) {
$name = $setting->name;
$pagesetting->{$name} = $setting->value;
}
return $pagesetting;
}
示例7: init
public static function init()
{
if (!self::$is_loaded) {
$settings = Record::findAllFrom('Setting');
foreach ($settings as $setting) {
self::$settings[$setting->name] = $setting->value;
}
self::$is_loaded = true;
}
}
示例8: __construct
public function __construct()
{
AuthUser::load();
if (!AuthUser::isLoggedIn()) {
echo 'Please Login';
header('location:index.php?job=login');
}
//首页最近文章
//$this->recent_post = Article::getPost(5, true);
//侧栏分类
$this->categories = Category::findAll();
if (is_array($this->categories) && count($this->categories) > 0) {
$temp = array();
foreach ($this->categories as $k => $v) {
$temp[$v->id] = get_object_vars($v);
}
$this->cahce_categories = $temp;
$temp = array();
}
//Tags 后期改进为热词形式
$hot_tags = Tag::findAll(20);
//mprint_r($hot_tags, '$hot_tags');
if (count($hot_tags) > 0) {
$first = current($hot_tags);
$last = end($hot_tags);
foreach ($hot_tags as $k => $v) {
$tags_list[$k]['word'] = $v->name;
$tags_list[$k]['size'] = tagClouds($v->count, $first->count, $last->count);
}
}
$this->tags_list = $tags_list;
$tags = Tag::findAll();
//var_dump($tags);
$content_tag = Record::findAllFrom('ContentTag');
//var_dump($content_tag);
//关系表中存在的文章ID以及tag集合到一个数组中tag_cache 避免在遍历生成文章静态页时重复读取数据库
//遍历所有tag 组合出方便调用的形式
if (is_array($tags) && count($tags) > 0) {
$temp_tags = array();
foreach ($tags as $k => $v) {
$temp_tags[$v->id] = $v->name;
}
}
//遍历关系表
if (is_array($content_tag) && count($content_tag) > 0) {
$this->cahce_tags = array();
foreach ($content_tag as $k => $v) {
if (isset($temp_tags[$v->tag_id])) {
$this->cahce_tags[$v->content_id][] = $temp_tags[$v->tag_id];
}
}
}
//清空临时数据
$tags = $content_tag = $temp_tags = array();
}
示例9: edit
function edit($id)
{
if (AuthUser::getId() != $id && !AuthUser::hasPermission('administrator')) {
Flash::set('error', __('You do not have permission to access the requested page!'));
redirect(get_url());
}
// check if trying to save
if (get_request_method() == 'POST') {
return $this->_edit($id);
}
if ($user = User::findById($id)) {
$this->display('user/edit', array('action' => 'edit', 'user' => $user, 'permissions' => Record::findAllFrom('Permission')));
} else {
Flash::set('error', __('User not found!'));
}
redirect(get_url('user'));
}
示例10: clear
function clear()
{
$error = false;
// We need to delete them one by one to make sure the filesystem is cleaned too.
$pages = Record::findAllFrom('FunkyCachePage');
foreach ($pages as $page) {
if (!$page->delete()) {
$error = true;
}
}
if ($error === false) {
Flash::set('success', 'Cache cleared successfully.');
} else {
Flash::set('error', 'One or more cached pages could not be deleted. Try manually from the commandline.');
}
$message = sprintf('Cache was cleared by :username.');
Observer::notify('log_event', $message, 'funky_cache', 5);
redirect(get_url('plugin/funky_cache/'));
}
示例11: _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]);
示例12: findAllLike
public static function findAllLike($tag)
{
return Record::findAllFrom(static::calledClass(), array('or_where' => array(array('name', 'like', '%:query%')), 'order_by' => array(array('count', 'desc'))), array(':query' => DB::expr($tag)));
}
示例13: create
public function create()
{
$this->_checkPermission();
$paths = func_get_args();
$this->display('sidebarlink/create', array('pages' => Record::findAllFrom('Page', 'parent_id=1 OR parent_id=0 order by parent_id,position')));
}
示例14: index
function index()
{
$this->display('layout/index', array('layouts' => Record::findAllFrom('Layout', '1=1 ORDER BY position')));
}
示例15: callback_view_page_page_metadata
/**
* Select page part forms for metadata.
*
* @param metadata metadata entries for this page
*/
public static function callback_view_page_page_metadata($metadata)
{
$selected = "";
$children_selected = "";
// Search for metadat for this plugin
foreach ($metadata as $m) {
if ($m->keyword == self::PLUGIN_ID) {
$selected = $m->value;
}
if ($m->keyword == self::PLUGIN_ID . '_children') {
$children_selected = $m->value;
}
}
self::Get_instance()->create_view('observers/form_type', array('page_part_forms' => Record::findAllFrom('PagePartForm', '1=1 ORDER BY name DESC'), 'selected' => $selected, 'children_selected' => $children_selected))->display();
}