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


PHP TikiDb::get方法代码示例

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


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

示例1: __construct

 function __construct()
 {
     $table = \TikiDb::get()->table('tiki_pages');
     $this->validationCallback = function ($slug) use($table) {
         return $table->fetchCount(['pageSlug' => $slug]) > 0;
     };
 }
开发者ID:rjsmelo,项目名称:tiki,代码行数:7,代码来源:SlugManager.php

示例2: tearDown

 function tearDown()
 {
     global $user;
     $user = null;
     parent::tearDown();
     TikiDb::get()->query('DELETE FROM `tiki_user_votings` WHERE `id` LIKE ?', array('test.%'));
 }
开发者ID:railfuture,项目名称:tiki-website,代码行数:7,代码来源:AggregationTest.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($since = $input->getOption('since')) {
         $since = strtotime($since);
     }
     $ignoreList = array();
     foreach ($input->getOption('ignore') as $object) {
         if (preg_match("/^(?P<type>\\w+):(?P<object>.+)\$/", $object, $parts)) {
             $ignoreList[] = $parts;
         }
     }
     $since = $since ?: 0;
     $logs = \TikiDb::get()->table('tiki_actionlog');
     $actions = $logs->fetchAll(array('timestamp' => 'lastModif', 'action', 'type' => 'objectType', 'object', 'detail' => 'comment'), array('lastModif' => $logs->greaterThan($since)), -1, -1, 'lastModif_asc');
     $queue = new \Tiki_Profile_Writer_Queue();
     foreach ($actions as $action) {
         $queue->add($action);
     }
     $writer = $this->getProfileWriter($input);
     if (count($ignoreList)) {
         foreach ($ignoreList as $entry) {
             $writer->addFake($entry['type'], $entry['object']);
         }
         $writer->save();
     }
     $queue->filterIncluded($writer);
     $queue->filterInstalled(new \Tiki_Profile_Writer_ProfileFinder());
     $output->writeln((string) $queue);
 }
开发者ID:jkimdon,项目名称:cohomeals,代码行数:29,代码来源:RecentChanges.php

示例4: action_create_from_url

 function action_create_from_url($input)
 {
     Services_Exception_Disabled::check('page_content_fetch');
     Services_Exception_Denied::checkGlobal('edit_article');
     $id = null;
     $title = null;
     $url = $input->url->url();
     if ($_SERVER['REQUEST_METHOD'] == 'POST' && $url) {
         $lib = TikiLib::lib('pagecontent');
         $data = $lib->grabContent($url);
         if (!$data) {
             throw new Services_Exception_FieldError($input->errorfield->text() ?: 'url', tr('Content could not be loaded.'));
         }
         $data['content'] = trim($data['content']) == '' ? $data['content'] : '~np~' . $data['content'] . '~/np~';
         $data['description'] = '';
         $data['author'] = '';
         $topicId = $input->topicId->int();
         $articleType = $input->type->text();
         $title = $data['title'];
         $hash = md5($data['title'] . $data['description'] . $data['content']);
         $id = TikiDb::get()->table('tiki_articles')->fetchOne('articleId', array('linkto' => $url)) ?: 0;
         if (!$id) {
             $tikilib = TikiLib::lib('tiki');
             $publication = $tikilib->now;
             $expire = $publication + 3600 * 24 * 365;
             $rating = 10;
             $artlib = TikiLib::lib('art');
             $id = $artlib->replace_article($title, $data['author'], $topicId, 'n', '', 0, '', '', $data['description'], $data['content'], $publication, $expire, $GLOBALS['user'], $id, 0, 0, $articleType, '', '', $url, '', '', $rating, 'n', '', '', '', '', 'y', true);
         }
     }
     $db = TikiDb::get();
     $topics = $db->table('tiki_topics')->fetchMap('topicId', 'name', array(), -1, -1, 'name_asc');
     $types = $db->table('tiki_article_types')->fetchColumn('type', array());
     return ['title' => tr('Create article from URL'), 'url' => $url, 'id' => $id, 'articleTitle' => $title, 'topics' => $topics, 'types' => $types];
 }
开发者ID:linuxwhy,项目名称:tiki-1,代码行数:35,代码来源:Controller.php

示例5: action_create

 function action_create($input)
 {
     global $prefs;
     $templates = $this->utilities->getTemplateList();
     if (0 === count($templates)) {
         throw new Services_Exception_Denied('No templates available to you');
     }
     $name = $input->name->text();
     $template = $input->template->int();
     if ($template && $name) {
         $templateInfo = $this->utilities->getTemplate($template);
         $perms = Perms::get('workspace', $template);
         if (!$perms->workspace_instantiate) {
             throw new Services_Exception_Denied();
         }
         $workspaceName = $name;
         $name = $templateInfo['name'] . $prefs['namespace_separator'] . $name;
         $transaction = TikiDb::get()->begin();
         $parts = explode($prefs['namespace_separator'], $name);
         $this->utilities->validateCategory($parts);
         $this->utilities->validatePerspective($name);
         $this->utilities->validatePage($name);
         $this->utilities->validateGroup($name);
         $values = array('category' => $this->utilities->createCategory($parts), 'perspective' => $this->utilities->createPerspective($name), 'page' => $this->utilities->createPage($name), 'group' => $this->utilities->createGroup($name));
         $values['namespace'] = $values['page'];
         $this->utilities->initialize($values);
         $this->utilities->applyTemplate($templateInfo, $values);
         $transaction->commit();
     }
     return array('title' => tr('Create Workspace'), 'templates' => $templates);
 }
开发者ID:rjsmelo,项目名称:tiki,代码行数:31,代码来源:Controller.php

示例6: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     global $prefs, $url_scheme, $url_host, $tikiroot, $url_port;
     $days = intval($input->getArgument('days')) ?: 7;
     if ($input->getOption('ssl')) {
         $url_scheme = 'https';
     }
     if ($input->hasOption('port')) {
         $url_port = (int) $input->getOption('port');
     }
     if ($input->hasOption('path')) {
         $tikiroot = $input->getOption('path');
         // Make sure slash before and after
         $tikiroot = rtrim($tikiroot, '/') . '/';
         $tikiroot = '/' . ltrim($tikiroot, '/');
     }
     $url_host = $input->getArgument('domain');
     $list = \TikiDb::get()->fetchAll("\n\t\t\tSELECT userId, login, email, IFNULL(p.value, ?) language\n\t\t\tFROM users_users u\n\t\t\t\tLEFT JOIN tiki_user_preferences p ON u.login = p.user AND p.prefName = 'language'", [$prefs['site_language']]);
     $monitormail = \TikiLib::lib('monitormail');
     $from = date('Y-m-d H:i:s', time() - $days * 24 * 3600);
     $to = date('Y-m-d H:i:s');
     foreach ($list as $info) {
         $success = $monitormail->sendDigest($info, $from, $to);
         if ($success) {
             $output->writeln("Digest sent to {$info['email']}");
         } else {
             $output->writeln("No data for {$info['email']}");
         }
     }
 }
开发者ID:linuxwhy,项目名称:tiki-1,代码行数:30,代码来源:NotificationDigestCommand.php

示例7: wikiplugin_votings

function wikiplugin_votings($data, $params)
{
    global $user;
    if (!isset($params['objectkey'])) {
        return '';
    } else {
        $key = $params['objectkey'];
    }
    $smarty = TikiLib::lib('smarty');
    $votings = TikiDb::get()->table('tiki_user_votings');
    $data = $votings->fetchRow(array('count' => $votings->count(), 'total' => $votings->sum('optionId')), array('id' => $key));
    $result = $votings->fetchAll(array('user'), array('id' => $key));
    foreach ($result as $res) {
        $field['users'][] = $res['user'];
    }
    $field['numvotes'] = $data['count'];
    $field['total'] = $data['total'];
    if ($field['numvotes']) {
        $field['voteavg'] = $field['total'] / $field['numvotes'];
    } else {
        $field['voteavg'] = 0;
    }
    // be careful optionId is the value - not the optionId
    $field['my_rate'] = $votings->fetchOne('optionId', array('id' => $key, 'user' => $user));
    $smarty->assign('wp_votings', $field);
    if (!empty($params['returnval']) && isset($field[$params['returnval']])) {
        return $field[$params['returnval']];
    } else {
        return '';
    }
}
开发者ID:rjsmelo,项目名称:tiki,代码行数:31,代码来源:wikiplugin_votings.php

示例8: action_toggle

 /**
  * Function to toggle relation. Sets relation when none set and then if there is a relation, it unsets.
  * @param $input
  * @return array with "relationId" as param. Null if relation is removed.
  * @throws Exception
  * @throws Services_Exception
  */
 function action_toggle($input)
 {
     $relation = $input->relation->none();
     $target_type = $input->target_type->none();
     $target_id = $input->target_id->none();
     $source_type = $input->source_type->none();
     $source_id = $input->source_id->none();
     // ensure the target, source, and relation info are passed to the service
     if (!$target_type || !$target_id || !$source_type || !$source_id || !$relation) {
         throw new Services_Exception(tr('Invalid input'), 400);
     }
     $relationlib = TikiLib::lib('relation');
     $tx = TikiDb::get()->begin();
     $relationId = $relationlib->get_relation_id($relation, $source_type, $source_id, $target_type, $target_id);
     // If there is not an existing relation, add the relation and trigger the add relation event.
     if (!$relationId) {
         $relationId = $relationlib->add_relation($relation, $source_type, $source_id, $target_type, $target_id);
         TikiLib::events()->trigger('tiki.relation.add', array('id' => $relationId, 'target_type' => $target_type, 'target_id' => $target_id, 'source_type' => $source_type, 'source_id' => $source_id, 'relation' => $relation));
     } else {
         //if there is a relation, remove the relation, trigger the event, and set the relationId to null
         $relationlib->remove_relation($relationId);
         TikiLib::events()->trigger('tiki.relation.remove', array('id' => $relationId, 'target_type' => $target_type, 'target_id' => $target_id, 'source_type' => $source_type, 'source_id' => $source_id, 'relation' => $relation));
         $relationId = null;
         // set the
     }
     $tx->commit();
     //return the relationId (new relation if added, null if removed)
     return array('relation_id' => $relationId);
 }
开发者ID:ameoba32,项目名称:tiki,代码行数:36,代码来源:Controller.php

示例9: getPermissionList

 private static function getPermissionList($writer, $objectType, $group)
 {
     switch ($objectType) {
         case 'category':
             $sub = "SELECT MD5(CONCAT('category', categId)) hash, categId objectId FROM tiki_categories";
             break;
         case 'forum':
             $sub = "SELECT MD5(CONCAT('forum', forumId)) hash, forumId objectId FROM tiki_forums";
             break;
         case 'tracker':
             $sub = "SELECT MD5(CONCAT('tracker', trackerId)) hash, trackerId objectId FROM tiki_trackers";
             break;
         case 'wiki page':
             $sub = "SELECT MD5(CONCAT('wiki page', LOWER(pageName))) hash, pageName objectId FROM tiki_pages";
             break;
         default:
             return array();
     }
     $db = TikiDb::get();
     $result = $db->fetchAll("\n\t\tSELECT i.objectId, permName\n\t\tFROM users_objectpermissions p\n\t\t\tINNER JOIN ({$sub}) i ON i.hash = p.objectId\n\t\tWHERE p.objectType = ? AND p.groupName = ?\n\t\t", array($objectType, $group));
     $map = [];
     foreach ($result as $row) {
         $id = $row['objectId'];
         if (!isset($map[$id])) {
             $map[$id] = array('type' => $objectType, 'id' => $writer->getReference($objectType, $id), 'allow' => []);
         }
         // Strip tiki_p_
         $map[$id]['allow'][] = substr($row['permName'], 7);
     }
     return array_values($map);
 }
开发者ID:linuxwhy,项目名称:tiki-1,代码行数:31,代码来源:Installer.php

示例10: removeEmptyAttachmentGals

function removeEmptyAttachmentGals()
{
    $galleryTable = TikiDb::get()->table('tiki_file_galleries');
    $fileTable = TikiDb::get()->table('tiki_files');
    $galleriesToDelete = array();
    $attachmentGalleries = $galleryTable->fetchAll(array('galleryId', 'name'), array('type' => 'attachments'));
    foreach ($attachmentGalleries as $gal) {
        $files = $fileTable->fetchCount(array('galleryId' => $gal['galleryId']));
        if (!$files) {
            $galleriesToDelete[] = $gal;
            echo "Attachment gallery: #{$gal['galleryId']} \"{$gal['name']}\" is empty, and will be removed\n";
            ob_flush();
        }
    }
    if ($galleriesToDelete) {
        $prompt = 'Are you sure you want to permanently remove all these (' . count($galleriesToDelete) . ') galleries? There is no undo... (y/n): ';
        if (readSTDIN($prompt, array('y', 'n')) == 'y') {
            echo "\n\n\nDeleting...\n\n";
            foreach ($galleriesToDelete as $gal) {
                TikiLib::lib('filegal')->remove_file_gallery($gal['galleryId']);
                echo "Removed gallery: #{$gal['galleryId']} \"{$gal['name']}\"\n";
                ob_flush();
            }
        }
    } else {
        echo "No empty attachement galleries found\n";
        ob_flush();
    }
    $remaining = count($attachmentGalleries) - count($galleriesToDelete);
    echo "There are {$remaining} attachment galleries left that contain files.\n";
    ob_flush();
}
开发者ID:linuxwhy,项目名称:tiki-1,代码行数:32,代码来源:remove_empty_wiki_attachment_filegals.php

示例11: gatherVoteData

 private function gatherVoteData()
 {
     global $user;
     $field = $this->getBaseFieldData();
     $trackerId = $this->getConfiguration('trackerId');
     $itemId = $this->getItemId();
     $votings = TikiDb::get()->table('tiki_user_votings');
     if ($field['type'] == 's' && $field['name'] == tra('Rating')) {
         // global rating to an item - value is the sum of the votes
         $key = 'tracker.' . $trackerId . '.' . $itemId;
     } elseif ($field['type'] == '*' || $field['type'] == 'STARS') {
         // field rating - value is the average of the votes
         $key = "tracker.{$trackerId}.{$itemId}." . $field['fieldId'];
     }
     $data = $votings->fetchRow(array('count' => $votings->count(), 'total' => $votings->sum('optionId')), array('id' => $key));
     $field['numvotes'] = $data['count'];
     $field['total'] = $data['total'];
     if ($field['numvotes']) {
         $field['voteavg'] = round($field['total'] / $field['numvotes'], 2);
     } else {
         $field['voteavg'] = 0;
     }
     // be careful optionId is the value - not the optionId
     $field['my_rate'] = $votings->fetchOne('optionId', array('id' => $key, 'user' => $user));
     return $field;
 }
开发者ID:hurcane,项目名称:tiki-azure,代码行数:26,代码来源:Rating.php

示例12: action_regenerate_slugs

 function action_regenerate_slugs($input)
 {
     global $prefs;
     Services_Exception_Denied::checkGlobal('admin');
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $pages = TikiDb::get()->table('tiki_pages');
         $initial = TikiLib::lib('slugmanager');
         $tracker = new Tiki\Wiki\SlugManager\InMemoryTracker();
         $manager = clone $initial;
         $manager->setValidationCallback($tracker);
         $list = $pages->fetchColumn('pageName', []);
         $pages->updateMultiple(['pageSlug' => null], []);
         foreach ($list as $page) {
             $slug = $manager->generate($prefs['wiki_url_scheme'], $page, $prefs['url_only_ascii'] === 'y');
             $count = 1;
             while ($pages->fetchCount(['pageSlug' => $slug]) && $count < 100) {
                 $count++;
                 $slug = $manager->generate($prefs['wiki_url_scheme'], $page . ' ' . $count, $prefs['url_only_ascii'] === 'y');
             }
             $tracker->add($page);
             $pages->update(['pageSlug' => $slug], ['pageName' => $page]);
         }
         TikiLib::lib('access')->redirect('tiki-admin.php?page=wiki');
     }
     return array('title' => tr('Regenerate Wiki URLs'));
 }
开发者ID:rjsmelo,项目名称:tiki,代码行数:26,代码来源:Controller.php

示例13: fetch

 function fetch($name, $filters)
 {
     $filters = array_filter($filters);
     $filters['object'] = $name;
     $table = TikiDb::get()->table('tiki_profile_symbols');
     return $table->fetchOne('value', $filters, 'creation_date_desc');
 }
开发者ID:rjsmelo,项目名称:tiki,代码行数:7,代码来源:SymbolLoader.php

示例14: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $confirm = $input->getOption('confirm');
     $perms = \Perms::get();
     if (!$perms->admin_file_galleries) {
         throw new \Exception('Tracker Clear: Admin permission required');
     }
     if ($confirm) {
         if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
             $output->writeln('<info>Deleting old filegal files...</info>');
         }
         \TikiLib::lib('filegal')->deleteOldFiles();
         if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
             $output->writeln('<info>Deleting old filegal files done</info>');
         }
     } else {
         $query = 'select * from `tiki_files` where `deleteAfter` < ? - `lastModif` and `deleteAfter` is not NULL and `deleteAfter` != \'\' order by galleryId asc';
         $now = time();
         $files = \TikiDb::get()->query($query, array($now));
         if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
             if ($files->numrows) {
                 $output->writeln("<comment>Files to delete:</comment>");
                 foreach ($files->result as $file) {
                     $old = ceil(abs($now - $file['lastModif']) / 86400);
                     $days = $old > 1 ? 'days' : 'day';
                     $deleteAfter = \TikiLib::lib('tiki')->get_short_datetime($file['deleteAfter']);
                     $output->writeln("<info>    \"{$file['name']}\" is {$old} {$days} old in gallery #{$file['galleryId']} (id #{$file['fileId']} deleteAfter {$deleteAfter})</info>");
                 }
             } else {
                 $output->writeln("<comment>No files to delete</comment>");
             }
         }
     }
 }
开发者ID:linuxwhy,项目名称:tiki-1,代码行数:34,代码来源:FilesDeleteoldCommand.php

示例15: build

 public static function build($className, DateTime $dt = null, TikiMail $tm = null, TikiLib $tikilib = null, $tikiPrefs = null)
 {
     $db = TikiDb::get();
     if (is_null($dt)) {
         $dt = new DateTime();
     }
     if (is_null($tm)) {
         $tm = new TikiMail();
     }
     if (is_null($tikilib)) {
         $tikilib = TikiLib::lib('tiki');
     }
     if (is_null($tikiPrefs)) {
         global $prefs;
         $tikiPrefs = $prefs;
     }
     switch ($className) {
         case 'Reports_Users':
             return new Reports_Users($db, $dt);
         case 'Reports_Cache':
             return new Reports_Cache($db, $dt);
         case 'Reports_Manager':
             global $userlib;
             return new Reports_Manager(Reports_Factory::build('Reports_Users', $dt, $tm, $tikilib), Reports_Factory::build('Reports_Cache', $dt, $tm, $tikilib), Reports_Factory::build('Reports_Send', $dt, $tm, $tikilib), $userlib);
         case 'Reports_Send':
             global $prefs;
             return new Reports_Send($dt, $tm, Reports_Factory::build('Reports_Send_EmailBuilder', $dt, $tm, $tikilib), $tikiPrefs);
         case 'Reports_Send_EmailBuilder':
             return new Reports_Send_EmailBuilder($tikilib, new Reports_Send_EmailBuilder_Factory());
         default:
             throw new Exception("Unknown class {$className}");
     }
 }
开发者ID:jkimdon,项目名称:cohomeals,代码行数:33,代码来源:Factory.php


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