当前位置: 首页>>代码示例>>PHP>>正文


PHP Query::output方法代码示例

本文整理汇总了PHP中Query::output方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::output方法的具体用法?PHP Query::output怎么用?PHP Query::output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Query的用法示例。


在下文中一共展示了Query::output方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: publications_userapi_getitemlinks

/**
 * utility function to pass individual item links to a caller
 *
 * @param $args['itemids'] array of item ids to get
 * @return array Array containing the itemlink(s) for the item(s).
 */
function publications_userapi_getitemlinks($args)
{
    $itemlinks = array();
    sys::import('xaraya.structures.query');
    $xartable = xarDB::getTables();
    $q = new Query('SELECT', $xartable['publications']);
    $q->addfield('id');
    $q->addfield('title');
    $q->addfield('description');
    $q->addfield('pubtype_id');
    $q->in('state', array(3, 4));
    if (!empty($args['itemids'])) {
        $itemids = explode(',', $args['itemids']);
        $q->in('id', $itemids);
    }
    $q->addorder('title');
    $q->run();
    $result = $q->output();
    if (empty($result)) {
        return $itemlinks;
    }
    foreach ($result as $item) {
        if (empty($item['title'])) {
            $item['title'] = xarML('Display Publication');
        }
        $itemlinks[$item['id']] = array('url' => xarModURL('publications', 'user', 'display', array('id' => $item['id'])), 'title' => $item['title'], 'label' => $item['description']);
    }
    return $itemlinks;
}
开发者ID:godboko,项目名称:modules,代码行数:35,代码来源:getitemlinks.php

示例2: calendar_userapi_getevents

function calendar_userapi_getevents($args)
{
    extract($args);
    $xartable = xarDB::getTables();
    $q = new Query('SELECT');
    $q->addtable($xartable['calendar_event']);
    $q->ge('start_time', $day->thisDay(TRUE));
    $q->lt('start_time', $day->nextDay(TRUE));
    if (!$q->run()) {
        return;
    }
    return $q->output();
}
开发者ID:godboko,项目名称:modules,代码行数:13,代码来源:getevents.php

示例3: publications_userapi_getpubcount

/**
 * get the number of publications per publication type
 * @param $args['state'] array of requested status(es) for the publications
 * @return array array(id => count), or false on failure
 */
function publications_userapi_getpubcount($args)
{
    if (!empty($args['state'])) {
        $statestring = 'all';
    } else {
        if (is_array($args['state'])) {
            sort($args['state']);
            $statestring = join('+', $args['state']);
        } else {
            $statestring = $args['state'];
        }
    }
    if (xarVarIsCached('Publications.PubCount', $statestring)) {
        return xarVarGetCached('Publications.PubCount', $statestring);
    }
    $pubcount = array();
    $dbconn = xarDB::getConn();
    $tables = xarDB::getTables();
    sys::import('xaraya.structures.query');
    $q = new Query('SELECT', $tables['publications']);
    $q->addfield('pubtype_id');
    $q->addfield('COUNT(state) AS count');
    $q->addgroup('pubtype_id');
    if (!empty($args['state'])) {
    } else {
        if (is_array($args['state'])) {
            $q->in('state', $args['state']);
        } else {
            $q->eq('state', $args['state']);
        }
    }
    //    $q->qecho();
    if (!$q->run()) {
        return;
    }
    $pubcount = array();
    foreach ($q->output() as $key => $value) {
        $pubcount[$value['pubtype_id']] = $value['count'];
    }
    xarVarSetCached('Publications.PubCount', $statestring, $pubcount);
    return $pubcount;
}
开发者ID:godboko,项目名称:modules,代码行数:47,代码来源:getpubcount.php

示例4: publications_userapi_get_sitemap_pages

/**
 * Get pages relative to a given page
 *
 * Filters:
 * Add an arg of the type $args['filter_foo'] = bar
 * will add a condition to the SELECT as
 * WHERE foo = bar
 *
 */
function publications_userapi_get_sitemap_pages($args)
{
    if (empty($args['itemid'])) {
        $args['itemid'] = 0;
    }
    if (empty($args['scope'])) {
        $args['scope'] = 'descendants';
    }
    if ($args['itemid'] == 0 && $args['scope'] == 'descendants') {
        $args['scope'] = 'all';
    }
    if (empty($args['sort'])) {
        $args['sort'] = 0;
    }
    // Make sure we have the base translation id
    if (!empty($args['itemid'])) {
        $args['itemid'] = xarMod::apiFunc('publications', 'user', 'gettranslationid', array('id' => $args['itemid'], 'locale' => xarModVars::get('publications', 'defaultlanguage')));
    }
    // Identify any filters
    $filters = array();
    foreach ($args as $k => $v) {
        if (strpos($k, 'filter_') === 0) {
            $argname = substr($k, 7);
            $filters[$argname] = $v;
        }
    }
    $xartable = xarDB::getTables();
    sys::import('xaraya.structures.query');
    $q = new Query();
    $q->addtable($xartable['publications'], 'p');
    switch ($args['scope']) {
        case 'all':
            $q->gt('p.leftpage_id', 0);
            break;
        case 'descendants':
            $q->addtable($xartable['publications'], 'root');
            $q->eq('root.id', $args['itemid']);
            $q->le('root.leftpage_id', 'expr:p.leftpage_id');
            $q->ge('root.rightpage_id', 'expr:p.rightpage_id');
            break;
        case 'children':
            $q->eq('p.parentpage_id', $args['itemid']);
            break;
        case 'siblings':
            $q->addtable($xartable['publications'], 'p1');
            $q->join('p.parentpage_id', 'p1.parentpage_id');
            $q->eq('p1.id', $args['itemid']);
            break;
    }
    if (!empty($args['itemtype'])) {
        $q->eq('p.pubtype_id', $args['itemtype']);
    }
    $q->eq('p.sitemap_flag', 1);
    $q->gt('p.state', 2);
    $q->addfield('p.id AS id');
    $q->addfield('p.name AS name');
    $q->addfield('p.title AS title');
    $q->addfield('p.description AS description');
    $q->addfield('p.sitemap_source_flag AS sitemap_source_flag');
    $q->addfield('p.sitemap_alias AS sitemap_alias');
    $q->addfield('p.pubtype_id AS pubtype_id');
    $q->addfield('p.rightpage_id AS rightpage_id');
    // Add any fiters we found
    foreach ($filters as $k => $v) {
        $q->eq('p.' . $k, $v);
    }
    // We can force alpha sorting, or else sort according to tree position
    if ($args['sort']) {
        $q->setorder('p.title');
    } else {
        $q->setorder('p.leftpage_id');
    }
    //    $q->qecho();
    $q->run();
    $pages = $q->output();
    $depthstack = array();
    foreach ($pages as $key => $page) {
        // Calculate the relative nesting level.
        // 'depth' is 0-based. Top level (root node) is zero.
        if (!empty($depthstack)) {
            while (!empty($depthstack) && end($depthstack) < $page['rightpage_id']) {
                array_pop($depthstack);
            }
        }
        $depthstack[$page['id']] = $page['rightpage_id'];
        $pages[$key]['depth'] = empty($depthstack) ? 0 : count($depthstack) - 1;
        // This item is the path for each page, based on page IDs.
        // It is effectively a list of ancestor IDs for a page.
        // FIXME: some paths seem to get a '0' root ID. They should only have real page IDs.
        $pages[$key]['idpath'] = array_keys($depthstack);
        $pathstack[$key] = $page['name'];
//.........这里部分代码省略.........
开发者ID:godboko,项目名称:modules,代码行数:101,代码来源:get_sitemap_pages.php

示例5: calendar_user_day

function calendar_user_day()
{
    $data = xarMod::apiFunc('calendar', 'user', 'getUserDateTimeInfo');
    $DayEvents = new Calendar_Day($data['cal_year'], $data['cal_month'], $data['cal_day'], CALENDAR_FIRST_DAY_OF_WEEK);
    $args = array('day' => &$Day);
    $day_endts = $DayEvents->getTimestamp() + xarModVars::get('calendar', 'day_end') + 3600;
    //        $events = xarMod::apiFunc('icalendar','user','getevents',$args);
    // get all the events. need to improve this query
    $xartable = xarDB::getTables();
    $q = new Query('SELECT', $xartable['calendar_event']);
    //        $q->qecho();
    if (!$q->run()) {
        return;
    }
    $events = $q->output();
    // Do some calculations to complete the entries' info
    $slots = array();
    // Loop through the events
    $eventcount = count($events);
    for ($j = 0; $j < $eventcount; $j++) {
        // make sure events don't go past the end of the day
        $events[$j]['end_time'] = min($events[$j]['end_time'], $day_endts);
        $placed = false;
        $slotcount = count($slots);
        for ($i = 0; $i < $slotcount; $i++) {
            if ($events[$j]['start_time'] >= $slots[$i][1]) {
                foreach ($slots as $slot) {
                    $events[$slot[0]]['neighbors'] = $slotcount;
                }
                $thisslot = $i;
                $slots = array(0 => array($j, $events[$j]['end_time']));
                $placed = true;
                break;
            }
        }
        if (!$placed) {
            $thisslot = $slotcount;
            $slots[] = array($j, $events[$j]['end_time']);
        }
        $events[$j]['place'] = $thisslot;
    }
    foreach ($slots as $slot) {
        $events[$slot[0]]['neighbors'] = $slotcount;
    }
    //foreach($events as $event) {var_dump($event);echo "<br />";}
    /*
    $selection = array();
    foreach ( $entries as $entry ) {
        $Hour = new Calendar_Hour(2000,1,1,1);
        $Hour->setTimeStamp($entry['start_time']);
    
        // Create the decorator, passing it the Hour
        $event = new Event($Hour);
    
        // Attach the payload
        $event->setEntry($entry);
    
        // Add the decorator to the selection
        $selection[] = $event;
    }
    */
    $DayDecorator = new DayEvent_Decorator($DayEvents);
    $DayDecorator->build($events);
    $data['Day'] =& $DayDecorator;
    $data['cal_sdow'] = CALENDAR_FIRST_DAY_OF_WEEK;
    return $data;
}
开发者ID:godboko,项目名称:modules,代码行数:67,代码来源:day.php

示例6: publications_userapi_getpages


//.........这里部分代码省略.........
    // If the request is to fetch a tree that *contains* a particular
    // page, then add the extra sub-queries in here.
    if (!empty($tree_contains_id) || !empty($tree_contains_name)) {
        $q->addtable($xartable['publications'], 'tpages_member');
        if (!empty($tree_contains_id)) {
            $q->eq('tpages_member.id', (int) $tree_contains_id);
        }
        if (!empty($tree_contains_name)) {
            $q->eq('tpages_member.name', (int) $tree_contains_name);
        }
        if (!empty($tree_ancestors)) {
            // We don't want the complete tree for the matching pages - just
            // their ancestors. This is useful for checking paths, without
            // fetching complete trees.
            $q->between('tpages_member.leftpage_id', 'expr:tpages.leftpage_id AND tpages.rightpage_id');
        } else {
            // Join to find the root page of the tree containing the required page.
            // This matches the complete tree for the root under the selected page.
            $q->addtable($xartable['publications'], 'tpages_root');
            $q->le('tpages_root.leftpage_id', 'expr:tpages_member.leftpage_id');
            $q->ge('tpages_root.rightpage_id', 'expr:tpages_member.rightpage_id');
            $q->between('tpages.leftpage_id', 'expr:tpages_root.leftpage_id AND tpages_root.rightpage_id');
            $q->eq('tpages_root.parentpage_id', 0);
        }
    }
    // This ordering cannot be changed
    // We want the pages in the order of the hierarchy.
    if (empty($count)) {
        $q->setorder('tpages.leftpage_id', 'ASC');
    }
    //    $q->qecho();
    $q->run();
    if ($count) {
        $pages = count($q->output());
    } else {
        $index = 0;
        $id2key = array();
        $pages = array();
        // Get all the page type details.
        $pagetypes = xarMod::apiFunc('publications', 'user', 'get_pubtypes', array('key' => 'id'));
        foreach ($q->output() as $row) {
            $id = (int) $row['id'];
            // At this point check the privileges of the page fetched.
            // To prevent broken trees, if a page is not assessible, prune
            // (ie discard) descendant pages of that page. Descendants will have
            // a left value between the left and right values of the
            // inaccessible page.
            if (!empty($prune_left)) {
                if ($row['leftpage_id'] <= $prune_left) {
                    // The current page is still a descendant of the unprivileged page.
                    continue;
                } else {
                    // We've reached a non-descendant - stop pruning now.
                    $prune_left = 0;
                }
            }
            // JDJ 2008-06-11: now only need ViewPublicationsPage to be able to select the page,
            // but ReadPublicationsPage to actually read it.
            // The lowest privilege will be inherited, so one page with only View privilege
            // will cause all descendent pages to have, at most, view privilege.
            // We still need to fetch full details of these view-only pages, but we must flag
            // then up in some way (status?). Displaying any of these pages would instead just
            // show the 'no privs' page.
            // Define admin access
            sys::import('modules.dynamicdata.class.properties.master');
            $accessproperty = DataPropertyMaster::getProperty(array('name' => 'access'));
开发者ID:godboko,项目名称:modules,代码行数:67,代码来源:getpages.php

示例7: getEvents

 public function getEvents($start_time, $end_time, $role_id)
 {
     // get all the events. need to improve this query and combine it with the query in the template
     $xartable = xarDB::getTables();
     $q = new Query('SELECT', $xartable['calendar_event']);
     $q->ge('start_time', $start_time);
     $q->lt('start_time', $end_time);
     $q->eq('role_id', $role_id);
     //        $q->qecho();
     if (!$q->run()) {
         return;
     }
     return $q->output();
 }
开发者ID:godboko,项目名称:modules,代码行数:14,代码来源:calendardisplay.php

示例8: publications_admin_clone

/**
 * Publications Module
 *
 * @package modules
 * @subpackage publications module
 * @category Third Party Xaraya Module
 * @version 2.0.0
 * @copyright (C) 2011 Netspan AG
 * @license GPL {@link http://www.gnu.org/licenses/gpl.html}
 * @author Marc Lutolf <mfl@netspan.ch>
 */
function publications_admin_clone()
{
    if (!xarSecurityCheck('ManagePublications')) {
        return;
    }
    if (!xarVarFetch('name', 'isset', $objectname, NULL, XARVAR_DONT_SET)) {
        return;
    }
    if (!xarVarFetch('ptid', 'isset', $ptid, NULL, XARVAR_DONT_SET)) {
        return;
    }
    if (!xarVarFetch('itemid', 'isset', $data['itemid'], NULL, XARVAR_DONT_SET)) {
        return;
    }
    if (!xarVarFetch('confirm', 'int', $confirm, 0, XARVAR_DONT_SET)) {
        return;
    }
    if (empty($data['itemid'])) {
        return xarResponse::NotFound();
    }
    // If a pubtype ID was passed, get the name of the pub object
    if (isset($ptid)) {
        $pubtypeobject = DataObjectMaster::getObject(array('name' => 'publications_types'));
        $pubtypeobject->getItem(array('itemid' => $ptid));
        $objectname = $pubtypeobject->properties['name']->value;
    }
    if (empty($objectname)) {
        return xarResponse::NotFound();
    }
    sys::import('modules.dynamicdata.class.objects.master');
    $data['object'] = DataObjectMaster::getObject(array('name' => $objectname));
    if (empty($data['object'])) {
        return xarResponse::NotFound();
    }
    // Security
    if (!$data['object']->checkAccess('update')) {
        return xarResponse::Forbidden(xarML('Clone #(1) is forbidden', $object->label));
    }
    $data['object']->getItem(array('itemid' => $data['itemid']));
    $data['authid'] = xarSecGenAuthKey();
    $data['name'] = $data['object']->properties['name']->value;
    $data['label'] = $data['object']->label;
    xarTplSetPageTitle(xarML('Clone Publication #(1) in #(2)', $data['itemid'], $data['label']));
    if ($confirm) {
        if (!xarSecConfirmAuthKey()) {
            return;
        }
        // Get the name for the clone
        if (!xarVarFetch('newname', 'str', $newname, "", XARVAR_NOT_REQUIRED)) {
            return;
        }
        if (empty($newname)) {
            $newname = $data['name'] . "_copy";
        }
        if ($newname == $data['name']) {
            $newname = $data['name'] . "_copy";
        }
        $newname = strtolower(str_ireplace(" ", "_", $newname));
        // Create the clone
        $data['object']->properties['name']->setValue($newname);
        $data['object']->properties['id']->setValue(0);
        $cloneid = $data['object']->createItem(array('itemid' => 0));
        // Create the clone's translations
        if (!xarVarFetch('clone_translations', 'int', $clone_translations, 0, XARVAR_NOT_REQUIRED)) {
            return;
        }
        if ($clone_translations) {
            // Get the info on all the objects to be cloned
            sys::import('xaraya.structures.query');
            $tables = xarDB::getTables();
            $q = new Query();
            $q->addtable($tables['publications'], 'p');
            $q->addtable($tables['publications_types'], 'pt');
            $q->join('p.pubtype_id', 'pt.id');
            $q->eq('parent_id', $data['itemid']);
            $q->addfield('p.id AS id');
            $q->addfield('pt.name AS name');
            $q->run();
            // Clone each one
            foreach ($q->output() as $item) {
                $object = DataObjectMaster::getObject(array('name' => $item['name']));
                $object->getItem(array('itemid' => $item['id']));
                $object->properties['parent']->value = $cloneid;
                $object->properties['id']->value = 0;
                $object->createItem(array('itemid' => 0));
            }
        }
        // Redirect if we came from somewhere else
        $current_listview = xarSession::getVar('publications_current_listview');
//.........这里部分代码省略.........
开发者ID:godboko,项目名称:modules,代码行数:101,代码来源:clone.php


注:本文中的Query::output方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。