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


PHP Pluf::factory方法代码示例

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


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

示例1: testFullRender

 public function testFullRender()
 {
     $renderer = Pluf::factory('Pluf_Text_Wiki_Renderer');
     $string = file_get_contents(dirname(__FILE__) . '/wikisample.txt');
     $render = file_get_contents(dirname(__FILE__) . '/wikisample.render.txt');
     $this->assertEquals($render, $renderer->render($string));
 }
开发者ID:burbuja,项目名称:pluf,代码行数:7,代码来源:PlufTextWikiTest.php

示例2: removeOrphanRepositories

 /**
  * Remove orphan repositories.
  */
 public static function removeOrphanRepositories()
 {
     $path = Pluf::f('idf_plugin_syncgit_base_repositories', '/home/git/repositories');
     if (!is_dir($path) || is_link($path)) {
         throw new Pluf_Exception_SettingError(sprintf('Directory %s does not exist! Setting "idf_plugin_syncgit_base_repositories not set.', $path));
     }
     if (!is_writable($path)) {
         throw new Exception(sprintf('Repository %s is not writable.', $path));
     }
     $projects = array();
     foreach (Pluf::factory('IDF_Project')->getList() as $project) {
         $projects[] = $project->shortname;
     }
     unset($project);
     $it = new DirectoryIterator($path);
     $orphans = array();
     while ($it->valid()) {
         if (!$it->isDot() && $it->isDir() && !in_array(basename($it->getFileName(), '.git'), $projects)) {
             $orphans[] = $it->getPathName();
         }
         $it->next();
     }
     if (count($orphans)) {
         $cmd = Pluf::f('idf_exec_cmd_prefix', '') . 'rm -rf ' . implode(' ', $orphans);
         exec($cmd);
         clearstatcache();
         while (list(, $project) = each($orphans)) {
             if (is_dir($project)) {
                 throw new Exception(sprintf('Cannot remove %s directory.', $project));
             }
         }
     }
 }
开发者ID:Br3nda,项目名称:indefero,代码行数:36,代码来源:Cron.php

示例3: current

 /**
  * Get the current item.
  */
 public function current()
 {
     $i = current($this->results);
     $doc = Pluf::factory($i['model_class'], $i['model_id']);
     $doc->_searchScore = $i['score'];
     return $doc;
 }
开发者ID:burbuja,项目名称:pluf,代码行数:10,代码来源:ResultSet.php

示例4: save

 /**
  * Send the reminder email.
  *
  */
 function save($commit = true)
 {
     if (!$this->isValid()) {
         throw new Exception(__('Cannot save the model from an invalid form.'));
     }
     $account = $this->cleaned_data['account'];
     $sql = new Pluf_SQL('email=%s OR login=%s', array($account, $account));
     $users = Pluf::factory('Pluf_User')->getList(array('filter' => $sql->gen()));
     $return_url = '';
     foreach ($users as $user) {
         if ($user->active) {
             $return_url = Pluf_HTTP_URL_urlForView('IDF_Views::passwordRecoveryInputCode');
             $tmpl = new Pluf_Template('idf/user/passrecovery-email.txt');
             $cr = new Pluf_Crypt(md5(Pluf::f('secret_key')));
             $code = trim($cr->encrypt($user->email . ':' . $user->id . ':' . time()), '~');
             $code = substr(md5(Pluf::f('secret_key') . $code), 0, 2) . $code;
             $url = Pluf::f('url_base') . Pluf_HTTP_URL_urlForView('IDF_Views::passwordRecovery', array($code), array(), false);
             $urlic = Pluf::f('url_base') . Pluf_HTTP_URL_urlForView('IDF_Views::passwordRecoveryInputCode', array(), array(), false);
             $context = new Pluf_Template_Context(array('url' => Pluf_Template::markSafe($url), 'urlik' => Pluf_Template::markSafe($urlic), 'user' => Pluf_Template::markSafe($user), 'key' => Pluf_Template::markSafe($code)));
             $email = new Pluf_Mail(Pluf::f('from_email'), $user->email, __('Password Recovery - InDefero'));
             $email->setReturnPath(Pluf::f('bounce_email', Pluf::f('from_email')));
             $email->addTextMessage($tmpl->render($context));
             $email->sendMail();
         }
         if (!$user->active and $user->first_name == '---') {
             $return_url = Pluf_HTTP_URL_urlForView('IDF_Views::registerInputKey');
             IDF_Form_Register::sendVerificationEmail($user);
         }
     }
     return $return_url;
 }
开发者ID:burbuja,项目名称:indefero,代码行数:35,代码来源:Password.php

示例5: getItem

 /**
  * Get an item to process.
  *
  * @return mixed False if no item to proceed.
  */
 public static function getItem()
 {
     $item = false;
     $db = Pluf::db();
     $db->begin();
     // In a transaction to not process the same item at
     // the same time from to processes.
     $gqueue = new Pluf_Queue();
     $items = $gqueue->getList(array('filter' => $db->qn('lock') . '=0', 'order' => 'creation_dtime ASC'));
     if ($items->count() > 0) {
         $item = $items[0];
         $item->lock = 1;
         $item->update();
     }
     $db->commit();
     if ($item === false) {
         return false;
     }
     // try to get the corresponding object
     $obj = Pluf::factory($item->model_class, $item->model_id);
     if ($obj->id != $item->model_id) {
         $obj = null;
     }
     return array('queue' => $item, 'item' => $obj);
 }
开发者ID:burbuja,项目名称:pluf,代码行数:30,代码来源:Processor.php

示例6: postSave

 function postSave($create = false)
 {
     if ($create) {
         // Check if more than one revision for this page. We do
         // not want to insert the first revision in the timeline
         // as the page itself is inserted.  We do not insert on
         // update as update is performed to change the is_head
         // flag.
         $sql = new Pluf_SQL('wikipage=%s', array($this->wikipage));
         $rev = Pluf::factory('IDF_WikiRevision')->getList(array('filter' => $sql->gen()));
         if ($rev->count() > 1) {
             IDF_Timeline::insert($this, $this->get_wikipage()->get_project(), $this->get_submitter());
             foreach ($rev as $r) {
                 if ($r->id != $this->id and $r->is_head) {
                     $r->is_head = false;
                     $r->update();
                 }
             }
         }
         $page = $this->get_wikipage();
         $page->update();
         // Will update the modification timestamp.
         IDF_Search::index($page);
     }
 }
开发者ID:Br3nda,项目名称:indefero,代码行数:25,代码来源:WikiRevision.php

示例7: initFields

 public function initFields($extra = array())
 {
     $this->user = $extra['user'];
     $this->project = $extra['project'];
     if ($this->user->hasPerm('IDF.project-owner', $this->project) or $this->user->hasPerm('IDF.project-member', $this->project)) {
         $this->show_full = true;
     }
     $this->fields['summary'] = new Pluf_Form_Field_Varchar(array('required' => true, 'label' => __('Summary'), 'initial' => '', 'widget_attrs' => array('maxlength' => 200, 'size' => 67)));
     $this->fields['description'] = new Pluf_Form_Field_Varchar(array('required' => true, 'label' => __('Description'), 'initial' => '', 'widget' => 'Pluf_Form_Widget_TextareaInput', 'widget_attrs' => array('cols' => 58, 'rows' => 7)));
     $sql = new Pluf_SQL('project=%s', array($this->project->id));
     $commits = Pluf::factory('IDF_Commit')->getList(array('order' => 'creation_dtime DESC', 'nb' => 10, 'filter' => $sql->gen()));
     $choices = array();
     foreach ($commits as $c) {
         $id = strlen($c->scm_id) > 10 ? substr($c->scm_id, 0, 10) : $c->scm_id;
         $ext = mb_strlen($c->summary) > 50 ? mb_substr($c->summary, 0, 47) . '...' : $c->summary;
         $choices[$id . ' - ' . $ext] = $c->scm_id;
     }
     $this->fields['commit'] = new Pluf_Form_Field_Varchar(array('required' => true, 'label' => __('Commit'), 'initial' => '', 'widget' => 'Pluf_Form_Widget_SelectInput', 'widget_attrs' => array('choices' => $choices)));
     $upload_path = Pluf::f('upload_issue_path', false);
     if (false === $upload_path) {
         throw new Pluf_Exception_SettingError(__('The "upload_issue_path" configuration variable was not set.'));
     }
     $md5 = md5(rand() . microtime() . Pluf_Utils::getRandomString());
     // We add .dummy to try to mitigate security issues in the
     // case of someone allowing the upload path to be accessible
     // to everybody.
     $filename = substr($md5, 0, 2) . '/' . substr($md5, 2, 2) . '/' . substr($md5, 4) . '/%s.dummy';
     $this->fields['patch'] = new Pluf_Form_Field_File(array('required' => true, 'label' => __('Patch'), 'move_function_params' => array('upload_path' => $upload_path, 'upload_path_create' => true, 'file_name' => $filename)));
     if ($this->show_full) {
         $this->fields['status'] = new Pluf_Form_Field_Varchar(array('required' => true, 'label' => __('Status'), 'initial' => 'New', 'widget_attrs' => array('maxlength' => 20, 'size' => 15)));
     }
 }
开发者ID:burbuja,项目名称:indefero,代码行数:32,代码来源:ReviewCreate.php

示例8: getOrAdd

 /**
  * Create a commit from a simple class commit info of a changelog.
  *
  * @param stdClass Commit info
  * @param IDF_Project Current project
  * @return IDF_Commit
  */
 public static function getOrAdd($change, $project)
 {
     $sql = new Pluf_SQL('project=%s AND scm_id=%s', array($project->id, $change->commit));
     $r = Pluf::factory('IDF_Commit')->getList(array('filter' => $sql->gen()));
     if ($r->count() > 0) {
         $r[0]->extra = new IDF_Gconf();
         $r[0]->extra->serialize = true;
         $r[0]->extra->setModel($r[0]);
         $r[0]->extra->initCache();
         return $r[0];
     }
     if (!isset($change->full_message)) {
         $change->full_message = '';
     }
     $scm = IDF_Scm::get($project);
     $commit = new IDF_Commit();
     $commit->project = $project;
     $commit->scm_id = $change->commit;
     $commit->summary = self::toUTF8($change->title);
     $commit->fullmessage = self::toUTF8($change->full_message);
     $commit->author = $scm->findAuthor($change->author);
     $commit->origauthor = self::toUTF8($change->author);
     $commit->creation_dtime = $change->date;
     $commit->create();
     $extra = $scm->getExtraProperties($change);
     $commit->extra = new IDF_Gconf();
     $commit->extra->serialize = true;
     // As we can store arrays
     $commit->extra->setModel($commit);
     foreach ($extra as $key => $val) {
         $commit->extra->setVal($key, $val);
     }
     $commit->notify($project->getConf());
     return $commit;
 }
开发者ID:burbuja,项目名称:indefero,代码行数:42,代码来源:Commit.php

示例9: tearDown

 function tearDown()
 {
     $db = Pluf::db();
     $schema = Pluf::factory('Pluf_DB_Schema', $db);
     $m = new Pluf_Permission();
     $schema->model = $m;
     $schema->dropTables();
 }
开发者ID:burbuja,项目名称:pluf,代码行数:8,代码来源:LoadDump.php

示例10: tearDown

 protected function tearDown()
 {
     $db = Pluf::db();
     $schema = Pluf::factory('Pluf_DB_Schema', $db);
     $m1 = new TestFormModel();
     $schema->model = $m1;
     $schema->dropTables();
 }
开发者ID:burbuja,项目名称:pluf,代码行数:8,代码来源:PlufFormTest.php

示例11: preDelete

 /**
  * Predelete to drop the row level permissions.
  */
 function preDelete()
 {
     if (Pluf::f('pluf_use_rowpermission', false)) {
         $_rpt = Pluf::factory('Pluf_RowPermission')->getSqlTable();
         $sql = new Pluf_SQL('owner_class=%s AND owner_id=%s', array($this->_a['model'], $this->_data['id']));
         $this->_con->execute('DELETE FROM ' . $_rpt . ' WHERE ' . $sql->gen());
     }
 }
开发者ID:burbuja,项目名称:pluf,代码行数:11,代码来源:Group.php

示例12: Pluf_Shortcuts_GetOneOr404

/**
 * Get an object by SQL or raise a 404 error.
 *
 * Usage:
 * <pre>
 * $obj = Pluf_Shortcuts_GetOneOr404('MyApp_Model',
 *                                   'path=%s AND status=%s',
 *                                    array('welcome', 1));
 * </pre>
 *
 * @param string Model
 * @param string Base SQL request
 * @param string Parameters for the base SQL
 * @return Object The found object
 */
function Pluf_Shortcuts_GetOneOr404($object, $bsql, $psql)
{
    $sql = new Pluf_SQL($bsql, $psql);
    $item = Pluf::factory($object)->getOne(array('filter' => $sql->gen()));
    if ($item != null) {
        return $item;
    }
    throw new Pluf_HTTP_Error404();
}
开发者ID:burbuja,项目名称:pluf,代码行数:24,代码来源:Shortcuts.php

示例13: testSimplePaginate

 public function testSimplePaginate()
 {
     $model = new TestFormModel();
     $pag = Pluf::factory('Pluf_Paginator', $model);
     $pag->action = '/permission/';
     $pag->items_per_page = 5;
     $render = file_get_contents(dirname(__FILE__) . '/rendersimplepaginate.html');
     $this->assertEquals($render, $pag->render());
     $this->assertEquals($pag->page_number, 2);
 }
开发者ID:burbuja,项目名称:pluf,代码行数:10,代码来源:PlufPaginatorTest.php

示例14: getFromString

 /**
  * Get the matching permission object from the permission string.
  *
  * @param string Permission string, for example 'Pluf_User.create'.
  * @return false|Pluf_Permission The matching permission or false.
  */
 public static function getFromString($perm)
 {
     list($app, $code) = explode('.', trim($perm));
     $sql = new Pluf_SQL('code_name=%s AND application=%s', array($code, $app));
     $perms = Pluf::factory('Pluf_Permission')->getList(array('filter' => $sql->gen()));
     if ($perms->count() != 1) {
         return false;
     }
     return $perms[0];
 }
开发者ID:burbuja,项目名称:pluf,代码行数:16,代码来源:Permission.php

示例15: dump

 /**
  * Given a model or model name, dump the content.
  *
  * If the object is given, only this single object is dumped else
  * the complete table.
  *
  * @param mixed Model object or model name
  * @param bool Serialize as JSON (true)
  * @return mixed Array or JSON string
  */
 public static function dump($model, $serialize = true)
 {
     if (is_object($model)) {
         return $serialize ? json_encode(array(self::prepare($model))) : array(self::prepare($model));
     }
     $out = array();
     foreach (Pluf::factory($model)->getList(array('order' => 'id ASC')) as $item) {
         $out[] = self::prepare($item);
     }
     return $serialize ? json_encode($out) : $out;
 }
开发者ID:burbuja,项目名称:pluf,代码行数:21,代码来源:Fixture.php


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