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


PHP FArrayHelper::emptyish方法代码示例

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


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

示例1: render

 /**
  * Draws the html form element
  *
  * @param   array  $data           To pre-populate element with
  * @param   int    $repeatCounter  Repeat group counter
  *
  * @return  string	elements html
  */
 public function render($data, $repeatCounter = 0)
 {
     $name = $this->getHTMLName($repeatCounter);
     $params = $this->getParams();
     $formModel = $this->getFormModel();
     $userEl = $formModel->getElement($params->get('user_element'), true);
     $thisUser = false;
     if ($userEl) {
         $data = $formModel->getData();
         $userId = FArrayHelper::getValue($data, $userEl->getFullName(true, false) . '_raw', 0);
         // Failed validation
         if (is_array($userId)) {
             $userId = FArrayHelper::getValue($userId, 0);
         }
         $thisUser = !empty($userId) ? JFactory::getUser($userId) : false;
     }
     $selected = $this->getValue($data, $repeatCounter);
     if (is_string($selected)) {
         $selected = json_decode($selected);
     }
     if (!$this->isEditable()) {
         if (!empty($thisUser)) {
             $selected = $thisUser->groups;
         }
         // Get the titles for the user groups.
         //if (count($selected) > 0)
         if (!FArrayHelper::emptyish($selected)) {
             $query = $this->_db->getQuery(true);
             $query->select($this->_db->qn('title'));
             $query->from($this->_db->qn('#__usergroups'));
             $query->where($this->_db->qn('id') . ' IN ( ' . implode(' , ', $selected) . ')');
             $this->_db->setQuery($query);
             $selected = $this->_db->loadColumn();
         }
     }
     $layout = $this->getLayout('form');
     $layoutData = new stdClass();
     $layoutData->isEditable = $this->isEditable();
     $layoutData->input = JHtml::_('access.usergroups', $name, $selected, true);
     $layoutData->selected = is_array($selected) ? implode(', ', $selected) : '';
     return $layout->render($layoutData);
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:50,代码来源:usergroup.php

示例2: doCron

 /**
  * Run all active cron jobs
  *
  * @return void
  */
 protected function doCron()
 {
     $app = JFactory::getApplication();
     $mailer = JFactory::getMailer();
     $config = JFactory::getConfig();
     $input = $app->input;
     if ($app->isAdmin() || $input->get('option') == 'com_acymailing') {
         return;
     }
     // $$$ hugh - don't want to run on things like AJAX calls
     if ($input->get('format', '') == 'raw') {
         return;
     }
     // Get all active tasks
     $this->db = FabrikWorker::getDbo(true);
     $this->query = $this->db->getQuery(true);
     $now = $input->get('fabrikcron_run', false);
     $this->log = FabTable::getInstance('Log', 'FabrikTable');
     if (!$now) {
         /* $$$ hugh - changed from using NOW() to JFactory::getDate(), to avoid time zone issues, see:
          * http://fabrikar.com/forums/showthread.php?p=102245#post102245
          * .. which seems reasonable, as we use getDate() to set 'lastrun' to at the end of this func
          */
         $nextRun = "CASE " . "WHEN unit = 'second' THEN DATE_ADD( lastrun, INTERVAL frequency SECOND )\n" . "WHEN unit = 'minute' THEN DATE_ADD( lastrun, INTERVAL frequency MINUTE )\n" . "WHEN unit = 'hour' THEN DATE_ADD( lastrun, INTERVAL frequency HOUR )\n" . "WHEN unit = 'day' THEN DATE_ADD( lastrun, INTERVAL frequency DAY )\n" . "WHEN unit = 'week' THEN DATE_ADD( lastrun, INTERVAL frequency WEEK )\n" . "WHEN unit = 'month' THEN DATE_ADD( lastrun, INTERVAL frequency MONTH )\n" . "WHEN unit = 'year' THEN DATE_ADD( lastrun, INTERVAL frequency YEAR ) END";
         $this->query->select("id, plugin, lastrun, unit, frequency, " . $nextRun . " AS nextrun")->from('#__{package}_cron')->where("published = '1'")->where("{$nextRun} < '" . JFactory::getDate()->toSql() . "'");
     } else {
         $this->query->select('id, plugin')->from("#__{package}_cron WHERE published = '1'");
     }
     $this->db->setQuery($this->query);
     $rows = $this->db->loadObjectList();
     if (empty($rows)) {
         return;
     }
     // register our shutdownHandler(), so we can re-publish and reschedule the event if the script errors out
     register_shutdown_function(array($this, 'shutdownHandler'));
     $this->log->message = '';
     JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_fabrik/models');
     /** @var FabrikFEModelPluginmanager $pluginManager */
     $pluginManager = JModelLegacy::getInstance('Pluginmanager', 'FabrikFEModel');
     $listModel = JModelLegacy::getInstance('list', 'FabrikFEModel');
     foreach ($rows as $row) {
         // assign $row to $this->row, as we may need it in shutdown handling
         $this->row = $row;
         // Load in the plugin
         $this->pluginModel = $pluginManager->getPluginFromId($this->row->id, 'Cron');
         $params = $this->pluginModel->getParams();
         $this->log->message = '';
         $this->log->id = null;
         $this->log->referring_url = '';
         $this->log->message_type = 'plg.cron.' . $this->row->plugin;
         if (!$this->pluginModel->queryStringActivated()) {
             continue;
         }
         if ($this->pluginModel->doRunGating()) {
             $this->query->clear()->update('#__{package}_cron')->set('published = 0')->where('id = ' . $this->db->quote($this->row->id));
             $this->db->setQuery($this->query);
             $this->db->execute();
         }
         $tid = (int) $params->get('table');
         $thisListModel = clone $listModel;
         if ($tid !== 0) {
             $thisListModel->setId($tid);
             $this->log->message .= "\n\n" . $this->row->plugin . "\n listid = " . $thisListModel->getId();
             if ($this->pluginModel->requiresTableData()) {
                 //$table = $thisListModel->getTable();
                 //$total = $thisListModel->getTotalRecords();
                 //$nav = $thisListModel->getPagination($total, 0, $total);
                 $cron_row_limit = (int) $params->get('cron_row_limit', 100);
                 $thisListModel->setLimits(0, $cron_row_limit);
                 $thisListModel->getPagination(0, 0, $cron_row_limit);
                 $data = $thisListModel->getData();
                 // for some reason this hoses up next query
                 //$this->log->message .= "\n" . $thisListModel->buildQuery();
             }
         } else {
             $data = array();
         }
         $this->pluginModel->process($data, $thisListModel);
         $this->log->message = $this->pluginModel->getLog() . "\n\n" . $this->log->message;
         $this->reschedule();
         // Log if asked for
         if ($params->get('log', 0) == 1) {
             $this->log->store();
         }
         // Email log message
         $recipient = explode(',', $params->get('log_email', ''));
         if (!FArrayHelper::emptyish($recipient)) {
             $subject = $config->get('sitename') . ': ' . $this->row->plugin . ' scheduled task';
             $mailer->sendMail($config->get('mailfrom'), $config->get('fromname'), $recipient, $subject, $this->log->message, true);
         }
     }
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:97,代码来源:fabrikcron.php


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