예제 #1
0
파일: JCSSUtil.php 프로젝트: Silwereth/core
 /**
  * Save combined pagevars.
  *
  * @param array  $files     Files.
  * @param string $ext       Extention.
  * @param string $cache_dir Cache directory.
  *
  * @return array Array of file with combined pagevars file and remote files
  */
 private static function save($files, $ext, $cache_dir)
 {
     $themevars = ModUtil::getVar('ZikulaThemeModule');
     $lifetime = $themevars['cssjscombine_lifetime'];
     $hash = md5(serialize($files) . UserUtil::getTheme());
     $cachedFile = "{$cache_dir}/{$hash}_{$ext}.php";
     $cachedFileUri = "{$hash}_{$ext}.php";
     if (is_readable($cachedFile) && ($lifetime == -1 || filemtime($cachedFile) + $lifetime > time())) {
         return System::getBaseUri() . '/jcss.php?f=' . $cachedFileUri;
     }
     switch ($ext) {
         case 'css':
             $ctype = 'text/css';
             break;
         case 'js':
             $ctype = 'text/javascript';
             break;
         default:
             $ctype = 'text/plain';
             break;
     }
     $includedFiles = array();
     $outputFiles = array();
     $contents = array();
     $dest = fopen($cachedFile, 'w');
     foreach ($files as $file) {
         if (!empty($file)) {
             // skip remote files from combining
             if (is_file($file)) {
                 self::readfile($contents, $file, $ext);
                 $includedFiles[] = $file;
             } else {
                 $outputFiles[] = $file;
             }
         }
     }
     array_unshift($contents, "/* --- Combined file written: " . DateUtil::getDateTime() . " */\n\n");
     array_unshift($contents, "/* --- Combined files:\n" . implode("\n", $includedFiles) . "\n*/\n\n");
     $contents = implode('', $contents);
     // optional minify
     if ($themevars['cssjsminify'] && $ext == 'css') {
         // Remove comments.
         $contents = trim(preg_replace('/\\/\\*.*?\\*\\//s', '', $contents));
         // Compress whitespace.
         $contents = preg_replace('/\\s+/', ' ', $contents);
         // Additional whitespace optimisation -- spaces around certain tokens is not required by CSS
         $contents = preg_replace('/\\s*(;|\\{|\\}|:|,)\\s*/', '\\1', $contents);
     }
     global $ZConfig;
     $signingKey = md5(serialize($ZConfig['DBInfo']['databases']['default']));
     $signature = md5($contents . $ctype . $lifetime . $themevars['cssjscompress'] . $signingKey);
     $data = array('contents' => $contents, 'ctype' => $ctype, 'lifetime' => $lifetime, 'gz' => $themevars['cssjscompress'], 'signature' => $signature);
     fwrite($dest, serialize($data));
     fclose($dest);
     $combined = System::getBaseUri() . '/jcss.php?f=' . $cachedFileUri;
     array_unshift($outputFiles, $combined);
     return $outputFiles;
 }
예제 #2
0
 /**
  * Create an object of the reuqested type and set the cr_date and cr_uid fields.
  *
  * @param string $type The type of the object to create.
  *
  * @return The newly created object
  */
 public static function createObject($type)
 {
     $dbtable = DBUtil::getTables();
     if (!$dbtable[$type]) {
         throw new \Exception(__f('%1$s: Unable to reference object type [%2$s]', array('ObjectUtil::createObject', $type)));
     }
     $obj = array();
     $obj['__TYPE__'] = $type;
     $obj['cr_date'] = DateUtil::getDateTime();
     $obj['cr_uid'] = UserUtil::getVar('uid');
     return $obj;
 }
예제 #3
0
파일: User.php 프로젝트: projectesIF/Sirius
    /**
     * Show the form for make new bookings
     * @author	Albert Pérez Monfort (aperezm@xtec.cat)
     * @author	Josep Ferràndiz Farré (jferran6@xtec.cat)
     * @return	The booking form
     */
    public function formulari_assigna($args) {
        $sid = FormUtil::getPassedValue('sid', isset($args['sid']) ? $args['sid'] : null, 'GET');
        $dow = FormUtil::getPassedValue('dow', isset($args['dow']) ? $args['dow'] : 0, 'GET');
        $fh = FormUtil::getPassedValue('fh', isset($args['fh']) ? $args['fh'] : 0, 'GET');
        $sot = FormUtil::getPassedValue('sot', isset($args['sot']) ? $args['sot'] : 0, 'GET'); // sot = 1 shows form over books table
        $bookingDate = FormUtil::getPassedValue('d', isset($args['d']) ? $args['d'] : null, 'GET');

        $currentDate = date('Y-m-d', strtotime($args['cdate']));

        // Security check
        if (!SecurityUtil::checkPermission('IWbookings::', "::", ACCESS_ADD)) {
            throw new Zikula_Exception_Forbidden();
        }

        $espai = ModUtil::apiFunc('IWbookings', 'user', 'get', array('sid' => $sid));

        if ($espai['mdid'] != 0) {
            //Busquem les franges hor�ries i les tornem en forma de matriu per un MultiSelect
            $franges = ModUtil::apiFunc('IWbookings', 'user', 'getall_hores_MS', array('mdid' => $espai['mdid']));
            $period = $franges[$fh]['id'];
        }

        //$period = (isset($period) && $period >= 0) ? $franges[$fh]['id'] : null;
        //echo "<pre>"; var_dump($franges); echo "</pre>";
        //Construim l'array dels dies per el formulari
        (ModUtil::getVar('IWbookings', 'weekends')) ?
                        $dia = array(array('id' => '1', 'name' => $this->__('Monday')),
                    array('id' => '2', 'name' => $this->__('Tuesday')),
                    array('id' => '3', 'name' => $this->__('Wednesday')),
                    array('id' => '4', 'name' => $this->__('Thursday')),
                    array('id' => '5', 'name' => $this->__('Friday')),
                    array('id' => '6', 'name' => $this->__('Saturday')),
                    array('id' => '7', 'name' => $this->__('Sunday'))) :
                        $dia = array(array('id' => '1', 'name' => $this->__('Monday')),
                    array('id' => '2', 'name' => $this->__('Tuesday')),
                    array('id' => '3', 'name' => $this->__('Wednesday')),
                    array('id' => '4', 'name' => $this->__('Thursday')),
                    array('id' => '5', 'name' => $this->__('Friday')));

        $week = ModUtil::apiFunc('IWbookings', 'user', 'getWeek', array('date' => $currentDate,
                    'format' => 'ymd'));
        $startDate = $week['start'];
        $fields = explode('-', $startDate);
        $dies_dates = array();

        if ($currentDate == DateUtil::getDateTime('', "%Y-%m-%d")) {
            $j = date("w", DateUtil::makeTimestamp($currentDate));
            ($j == 0) ? $j = 7 : "";
        } else {
            $j = 1;
        }

        for ($i = $j; $i <= count($dia); ++$i) {
            $dies_dates[$i - $j] = DateUtil::buildDatetime($fields[0], $fields[1], $fields[2] + $i - 1, 0, 0, 0, '%d-%m-%Y');
        }

        $showDays = array();
        for ($i = $j; $i <= (count($dia)); ++$i) {
            $showDays[$i - $j] = array('id' => $dia[$i - 1]['id'],
                'name' => $dia[$i - 1]['name']);
        }

        $hora = array(array('id' => '0', 'name' => '08'),
            array('id' => '1', 'name' => '09'),
            array('id' => '2', 'name' => '10'),
            array('id' => '3', 'name' => '11'),
            array('id' => '4', 'name' => '12'),
            array('id' => '5', 'name' => '13'),
            array('id' => '6', 'name' => '14'),
            array('id' => '7', 'name' => '15'),
            array('id' => '8', 'name' => '16'),
            array('id' => '9', 'name' => '17'),
            array('id' => '10', 'name' => '18'),
            array('id' => '11', 'name' => '19'),
            array('id' => '12', 'name' => '20'),
            array('id' => '13', 'name' => '21'),
            array('id' => '14', 'name' => '22'));

        $minut = array(array('id' => '0', 'name' => '00'),
            array('id' => '1', 'name' => '05'),
            array('id' => '2', 'name' => '10'),
            array('id' => '3', 'name' => '15'),
            array('id' => '4', 'name' => '20'),
            array('id' => '5', 'name' => '25'),
            array('id' => '6', 'name' => '30'),
            array('id' => '7', 'name' => '35'),
            array('id' => '8', 'name' => '40'),
            array('id' => '9', 'name' => '45'),
            array('id' => '10', 'name' => '50'),
            array('id' => '11', 'name' => '55'));

        // If the user is admin can make books in name of other users
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $professorat = '';
        if (SecurityUtil::checkPermission('IWbookings::', "::", ACCESS_ADMIN)) {
            $professorat = ModUtil::func('IWmain', 'user', 'getMembersGroup', array('gid' => ModUtil::getVar('IWbookings', 'group'),
                        'sv' => $sv));
            if (empty($professorat)) {
                throw new Zikula_Exception_Forbidden($this->__('Permanent bookings are not possible as long as the group is empty. Please check module configuration'));
            } else {
                sort($professorat);
            }
        }

        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $username = ModUtil::func('IWmain', 'user', 'getUserInfo', array('uid' => UserUtil::getVar('uid'),
                    'info' => 'ncc',
                    'sv' => $sv));

        // Extra frames to add
        $found = false;
        //$franges = array();
        $extra_frames = array();
        if ($espai['mdid'] != 0) {
            $i = 0;
            foreach ($franges as $franja) {
                if ($franja['name'] == $period) {
                    $found = true;
                } else {
                    if ($found) {
                        $franja['pos'] = $i;
                        $extra_frames[] = $franja;
                        $i++;
                    }
                }
            }
        }

        return $this->view->assign('dayofweek', $dow)
                        ->assign('bookingDate', $bookingDate)
                        ->assign('period', $period)
                        ->assign('sot', $sot)
                        ->assign('fh', $fh)
                        ->assign('dayofweek1', $dow + 1)
                        ->assign('franges', $franges)
                        ->assign('diasetmana', $dia[$dow]['name'])
                        ->assign('dia', $showDays)
                        ->assign('dates', $dies_dates)
                        ->assign('hora', $hora)
                        ->assign('minut', $minut)
                        ->assign('sid', $sid)
                        ->assign('user', UserUtil::getVar('uid'))
                        ->assign('professorat', $professorat)
                        ->assign('username', $username)
                        ->assign('extra_frames', $extra_frames)
                        ->fetch('IWbookings_user_assigna_frm.htm');
    }