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


PHP SpoonFile::setContent方法代码示例

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


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

示例1: buildCache

 /**
  * Build navigation cache file.
  *
  * @return	void
  */
 public function buildCache()
 {
     // init
     $navigationTree = '';
     // build tree starting with the root
     $this->buildNavigation(0, $navigationTree);
     // start generating PHP
     $value = '<?php' . "\n";
     $value .= '/**' . "\n";
     $value .= ' *' . "\n";
     $value .= ' * This file is generated by the Backend, it contains' . "\n";
     $value .= ' * more information about the navigation in the backend. Do NOT edit.' . "\n";
     $value .= ' * ' . "\n";
     $value .= ' * @author		Backend' . "\n";
     $value .= ' * @generated	' . date('Y-m-d H:i:s') . "\n";
     $value .= ' */' . "\n";
     $value .= "\n";
     $value .= "\$navigation = array(\n";
     // add navigation tree
     $value .= $navigationTree;
     // close php
     $value .= ");\n";
     $value .= "\n";
     $value .= '?>';
     // store
     SpoonFile::setContent(BACKEND_CACHE_PATH . '/navigation/navigation.php', $value);
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:32,代码来源:navigation.php

示例2: buildCache

    /**
     * Build the language files
     *
     * @return	void
     * @param	string $language		The language to build the locale-file for.
     * @param	string $application		The application to build the locale-file for.
     */
    public static function buildCache($language, $application)
    {
        // get db
        $db = BackendModel::getDB();
        // get types
        $types = $db->getEnumValues('locale', 'type');
        // get locale for backend
        $locale = (array) $db->getRecords('SELECT type, module, name, value
											FROM locale
											WHERE language = ? AND application = ?
											ORDER BY type ASC, name ASC, module ASC', array((string) $language, (string) $application));
        // start generating PHP
        $value = '<?php' . "\n\n";
        $value .= '/**' . "\n";
        $value .= ' *' . "\n";
        $value .= ' * This file is generated by Fork CMS, it contains' . "\n";
        $value .= ' * more information about the locale. Do NOT edit.' . "\n";
        $value .= ' * ' . "\n";
        $value .= ' * @author		Fork CMS' . "\n";
        $value .= ' * @generated	' . date('Y-m-d H:i:s') . "\n";
        $value .= ' */' . "\n";
        $value .= "\n";
        // loop types
        foreach ($types as $type) {
            // default module
            $modules = array('core');
            // continue output
            $value .= "\n";
            $value .= '// init var' . "\n";
            $value .= '$' . $type . ' = array();' . "\n";
            $value .= '$' . $type . '[\'core\'] = array();' . "\n";
            // loop locale
            foreach ($locale as $i => $item) {
                // types match
                if ($item['type'] == $type) {
                    // new module
                    if (!in_array($item['module'], $modules)) {
                        $value .= '$' . $type . '[\'' . $item['module'] . '\'] = array();' . "\n";
                        $modules[] = $item['module'];
                    }
                    // parse
                    if ($application == 'backend') {
                        $value .= '$' . $type . '[\'' . $item['module'] . '\'][\'' . $item['name'] . '\'] = \'' . str_replace('\\"', '"', addslashes($item['value'])) . '\';' . "\n";
                    } else {
                        $value .= '$' . $type . '[\'' . $item['name'] . '\'] = \'' . str_replace('\\"', '"', addslashes($item['value'])) . '\';' . "\n";
                    }
                    // unset
                    unset($locale[$i]);
                }
            }
        }
        // close php
        $value .= "\n";
        $value .= '?>';
        // store
        SpoonFile::setContent(constant(mb_strtoupper($application) . '_CACHE_PATH') . '/locale/' . $language . '.php', $value);
    }
开发者ID:netconstructor,项目名称:forkcms,代码行数:64,代码来源:model.php

示例3: write

 /**
  * Write an error/custom message to the log.
  *
  * @return	void
  * @param	string $message			The messages that should be logged.
  * @param	string[optional] $type	The type of message you want to log, possible values are: error, custom.
  */
 public static function write($message, $type = 'error')
 {
     // milliseconds
     list($milliseconds) = explode(' ', microtime());
     $milliseconds = round($milliseconds * 1000, 0);
     // redefine var
     $message = date('Y-m-d H:i:s') . ' ' . $milliseconds . 'ms | ' . $message . "\n";
     $type = SpoonFilter::getValue($type, array('error', 'custom'), 'error');
     // file
     $file = self::getPath() . '/' . $type . '.log';
     // rename if needed
     if ((int) @filesize($file) >= self::MAX_FILE_SIZE * 1024) {
         // start new log file
         SpoonDirectory::move($file, $file . '.' . date('Ymdhis'));
     }
     // write content
     SpoonFile::setContent($file, $message, true, true);
 }
开发者ID:JonckheereM,项目名称:Public,代码行数:25,代码来源:log.php

示例4: setBusyFile

 /**
  * Set the busy file
  *
  * @return	void
  */
 protected function setBusyFile()
 {
     // do not set busy file in debug mode
     if (SPOON_DEBUG) {
         return;
     }
     // build path
     $path = BACKEND_CACHE_PATH . '/cronjobs/' . $this->getId() . '.busy';
     // init var
     $isBusy = false;
     // does the busy file already exists.
     if (SpoonFile::exists($path)) {
         $isBusy = true;
         // grab counter
         $counter = (int) SpoonFile::getContent($path);
         // check the counter
         if ($counter > 9) {
             // build class name
             $className = 'Backend' . SpoonFilter::toCamelCase($this->getModule() . '_cronjob_' . $this->getAction());
             // notify user
             throw new BackendException('Cronjob (' . $className . ') is still busy after 10 runs, check it out!');
         }
     } else {
         $counter = 0;
     }
     // increment counter
     $counter++;
     // store content
     SpoonFile::setContent($path, $counter, true, false);
     // if the cronjob is busy we should NOT proceed
     if ($isBusy) {
         exit;
     }
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:39,代码来源:base.php

示例5: parseToFile

 /**
  * Write the feed into a file
  *
  * @param	string $path	The path (and filename) where the feed should be written.
  */
 public function parseToFile($path)
 {
     // get xml
     $XML = $this->buildXML();
     // write content
     SpoonFile::setContent((string) $path, $XML, false, true);
 }
开发者ID:jincongho,项目名称:clienthub,代码行数:12,代码来源:rss.php

示例6: correct

 public static function correct(&$frm)
 {
     if ($frm->getField('photo')->isFilled()) {
         $imagename = uniqid();
         SpoonFile::setContent(IMAGE_PATH . '/' . $imagename . '.' . $frm->getField('photo')->getExtension(), gzcompress(SpoonFile::getContent($frm->getField('photo')->getTempFileName()), 9));
         //create Thumbnail
         $frm->getField('photo')->createThumbnail(IMAGE_PATH . '/' . $imagename . '_thumbnail.' . $frm->getField('photo')->getExtension(), 130, 130);
         SpoonFile::setContent(IMAGE_PATH . '/' . $imagename . '_thumbnail.' . $frm->getField('photo')->getExtension(), gzcompress(SpoonFile::getContent(IMAGE_PATH . '/' . $imagename . '_thumbnail.' . $frm->getField('photo')->getExtension()), 9));
     }
     if ($frm->getField('attachment')->isFilled()) {
         $attachname = uniqid();
         SpoonFile::setContent(ATTACH_PATH . '/' . $attachname . '.' . $frm->getField('attachment')->getExtension(), gzcompress(SpoonFile::getContent($frm->getField('attachment')->getTempFileName()), 9));
     }
     $company = "";
     for ($i = 1; $i < 6; $i++) {
         $company .= $frm->getField('company' . $i)->getValue() . ', ' . $frm->getField('registerno' . $i)->getValue() . ', ' . $frm->getField('companyno' . $i)->getValue() . ', ' . $frm->getField('companyemail' . $i)->getValue() . ', ' . $frm->getField('shareholder' . $i)->getValue() . ', ' . $frm->getField('registeraddr' . $i)->getValue() . ', ' . $frm->getField('businessaddr' . $i)->getValue() . ', ';
     }
     $company = substr($company, 0, -2);
     //company field names
     $values = array();
     for ($i = 1; $i < 6; $i++) {
         $values = array_merge($values, array('company' . $i, 'registerno' . $i, 'companyno' . $i, 'companyemail' . $i, 'shareholder' . $i, 'registeraddr' . $i, 'businessaddr' . $i));
     }
     $values = array_merge($frm->getValues(array_merge(array('form', 'submit', '_utf8'), $values)), $frm->getField('photo')->isFilled() ? array('photo' => $imagename, 'photoext' => $frm->getField('photo')->getExtension()) : array(), $frm->getField('attachment')->isFilled() ? array('attachment' => $attachname, 'attachext' => $frm->getField('attachment')->getExtension()) : array(), array("company" => $company, 'lastupdate' => time()));
     foreach ($values as $key => $value) {
         if ($value == NULL) {
             unset($values[$key]);
         }
     }
     return $values;
 }
开发者ID:jincongho,项目名称:clienthub,代码行数:31,代码来源:profile.form.php

示例7: stringToArray

 /**
  * Converts a CSV-formatted string to an array
  *
  * @return	array
  * @param	string $string					The string you wish to convert to an array.
  * @param	array[optional] $columns		The column names you want to use.
  * @param	array[optional] $excludeColumns	The columns to exclude.
  * @param	string[optional] $delimiter		The field delimiter of the CSV.
  * @param	string[optional] $enclosure		The enclosure character of the CSV.
  */
 public static function stringToArray($string, array $columns = array(), array $excludeColumns = null, $delimiter = ',', $enclosure = '"')
 {
     // reset variables
     $string = (string) $string;
     $filename = dirname(__FILE__) . '/' . uniqid();
     // save a tempfile
     SpoonFile::setContent($filename, $string);
     // return the file to array
     $array = self::fileToArray($filename, $columns, $excludeColumns, $delimiter, $enclosure);
     // remove the created file
     SpoonFile::delete($filename);
     // return the array
     return $array;
 }
开发者ID:jincongho,项目名称:clienthub,代码行数:24,代码来源:csv.php

示例8: execute

    /**
     * Execute the action
     *
     * @return	void
     */
    public function execute()
    {
        // no timelimit
        set_time_limit(0);
        // get database
        $db = BackendModel::getDB(true);
        // create log
        $log = new SpoonLog('custom', BACKEND_CACHE_PATH . '/logs/events');
        // get process-id
        $pid = getmypid();
        // store PID
        SpoonFile::setContent(BACKEND_CACHE_PATH . '/hooks/pid', $pid);
        // loop forever
        while (true) {
            // get 1 item
            $item = $db->getRecord('SELECT *
									FROM hooks_queue
									WHERE status = ?
									LIMIT 1', array('queued'));
            // any item?
            if (!empty($item)) {
                // init var
                $processedSuccesfully = true;
                // set item as busy
                $db->update('hooks_queue', array('status' => 'busy'), 'id = ?', array($item['id']));
                // unserialize data
                $item['callback'] = unserialize($item['callback']);
                $item['data'] = unserialize($item['data']);
                // check if the item is callable
                if (!is_callable($item['callback'])) {
                    // in debug mode we want to know if there are errors
                    if (SPOON_DEBUG) {
                        throw new BackendException('Invalid callback.');
                    }
                    // set to error state
                    $db->update('hooks_queue', array('status' => 'error'), 'id = ?', $item['id']);
                    // reset state
                    $processedSuccesfully = false;
                    // logging when we are in debugmode
                    if (SPOON_DEBUG) {
                        $log->write('Callback (' . serialize($item['callback']) . ') failed.');
                    }
                }
                try {
                    // logging when we are in debugmode
                    if (SPOON_DEBUG) {
                        $log->write('Callback (' . serialize($item['callback']) . ') called.');
                    }
                    // call the callback
                    $return = call_user_func($item['callback'], $item['data']);
                    // failed?
                    if ($return === false) {
                        // set to error state
                        $db->update('hooks_queue', array('status' => 'error'), 'id = ?', $item['id']);
                        // reset state
                        $processedSuccesfully = false;
                        // logging when we are in debugmode
                        if (SPOON_DEBUG) {
                            $log->write('Callback (' . serialize($item['callback']) . ') failed.');
                        }
                    }
                } catch (Exception $e) {
                    // set to error state
                    $db->update('hooks_queue', array('status' => 'error'), 'id = ?', $item['id']);
                    // reset state
                    $processedSuccesfully = false;
                    // logging when we are in debugmode
                    if (SPOON_DEBUG) {
                        $log->write('Callback (' . serialize($item['callback']) . ') failed.');
                    }
                }
                // everything went fine so delete the item
                if ($processedSuccesfully) {
                    $db->delete('hooks_queue', 'id = ?', $item['id']);
                }
                // logging when we are in debugmode
                if (SPOON_DEBUG) {
                    $log->write('Callback (' . serialize($item['callback']) . ') finished.');
                }
            } else {
                // remove the file
                SpoonFile::delete(BACKEND_CACHE_PATH . '/hooks/pid');
                // stop the script
                exit;
            }
        }
    }
开发者ID:netconstructor,项目名称:forkcms,代码行数:92,代码来源:process_queued_hooks.php

示例9: execute

 /**
  * Execute the action
  *
  * @return	void
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // get parameters
     $page = trim(SpoonFilter::getPostValue('page', null, ''));
     $identifier = trim(SpoonFilter::getPostValue('identifier', null, ''));
     // validate
     if ($page == '' || $identifier == '') {
         $this->output(self::BAD_REQUEST, null, 'No page provided.');
     }
     // init vars
     $filename = BACKEND_CACHE_PATH . '/analytics/' . $page . '_' . $identifier . '.txt';
     // does the temporary file still exits?
     $status = SpoonFile::getContent($filename);
     // no file - create one
     if ($status === false) {
         // create file with initial counter
         SpoonFile::setContent($filename, 'missing1');
         // return status
         $this->output(self::OK, array('status' => false), 'Temporary file was missing. We created one.');
     }
     // busy status
     if (strpos($status, 'busy') !== false) {
         // get counter
         $counter = (int) substr($status, 4) + 1;
         // file's been busy for more than hundred cycles - just stop here
         if ($counter > 100) {
             // remove file
             SpoonFile::delete($filename);
             // return status
             $this->output(self::ERROR, array('status' => 'timeout'), 'Error while retrieving data - the script took too long to retrieve data.');
         }
         // change file content to increase counter
         SpoonFile::setContent($filename, 'busy' . $counter);
         // return status
         $this->output(self::OK, array('status' => 'busy'), 'Data is being retrieved. (' . $counter . ')');
     }
     // unauthorized status
     if ($status == 'unauthorized') {
         // remove file
         SpoonFile::delete($filename);
         // remove all parameters from the module settings
         BackendModel::setModuleSetting($this->getModule(), 'session_token', null);
         BackendModel::setModuleSetting($this->getModule(), 'account_name', null);
         BackendModel::setModuleSetting($this->getModule(), 'table_id', null);
         BackendModel::setModuleSetting($this->getModule(), 'profile_title', null);
         // remove cache files
         BackendAnalyticsModel::removeCacheFiles();
         // clear tables
         BackendAnalyticsModel::clearTables();
         // return status
         $this->output(self::OK, array('status' => 'unauthorized'), 'No longer authorized.');
     }
     // done status
     if ($status == 'done') {
         // remove file
         SpoonFile::delete($filename);
         // return status
         $this->output(self::OK, array('status' => 'done'), 'Data retrieved.');
     }
     // missing status
     if (strpos($status, 'missing') !== false) {
         // get counter
         $counter = (int) substr($status, 7) + 1;
         // file's been missing for more than ten cycles - just stop here
         if ($counter > 10) {
             // remove file
             SpoonFile::delete($filename);
             // return status
             $this->output(self::ERROR, array('status' => 'missing'), 'Error while retrieving data - file was never created.');
         }
         // change file content to increase counter
         SpoonFile::setContent($filename, 'missing' . $counter);
         // return status
         $this->output(self::OK, array('status' => 'busy'), 'Temporary file was still in status missing. (' . $counter . ')');
     }
     /* FALLBACK - SOMETHING WENT WRONG */
     // remove file
     SpoonFile::delete($filename);
     // return status
     $this->output(self::ERROR, array('status' => 'error'), 'Error while retrieving data.');
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:88,代码来源:check_status.php

示例10: parseToFile

 /**
  * Parse the template to a file.
  */
 public function parseToFile()
 {
     SpoonFile::setContent($this->compileDirectory . '/' . $this->getCompileName($this->template), $this->getContent());
 }
开发者ID:jeroendesloovere,项目名称:library,代码行数:7,代码来源:compiler.php

示例11: writeHelperFile

    /**
     * Write a slideshows helper file for the specified module
     *
     * @param string $module The module to write the helper file for.
     */
    public static function writeHelperFile($module)
    {
        $camelcasedModule = ucwords($module);
        $helperFile = FRONTEND_MODULES_PATH . '/' . $module . '/engine/slideshows.php';
        if (!\SpoonFile::exists($helperFile)) {
            $content = '<?php
						class Frontend' . $camelcasedModule . 'SlideshowsModel
						{
							public static function getImages()
							{
								$db = FrontendModel::getContainer()->get(\'database\');
						
								// This should work with an interface so people know what fields to add.
								// For now, check slideshows/layout/templates/basic.tpl to mimick the array structure.
								$records = array();
						
								return $records;
							}
						}
						';
            \SpoonFile::setContent($helperFile, $content);
        }
    }
开发者ID:Comsa-Veurne,项目名称:modules,代码行数:28,代码来源:Helper.php

示例12: getRealData

 /**
  * Load the data
  */
 private function getRealData()
 {
     // no search term = no search
     if (!$this->term) {
         return;
     }
     // set url
     $this->pagination['url'] = FrontendNavigation::getURLForBlock('search') . '?form=search&q=' . $this->term;
     $this->pagination['limit'] = FrontendModel::getModuleSetting('search', 'overview_num_items', 20);
     // populate calculated fields in pagination
     $this->pagination['requested_page'] = $this->requestedPage;
     $this->pagination['offset'] = $this->pagination['requested_page'] * $this->pagination['limit'] - $this->pagination['limit'];
     // get items
     $this->items = FrontendSearchModel::search($this->term, $this->pagination['limit'], $this->pagination['offset']);
     // populate count fields in pagination
     // this is done after actual search because some items might be activated/deactivated (getTotal only does rough checking)
     $this->pagination['num_items'] = FrontendSearchModel::getTotal($this->term);
     $this->pagination['num_pages'] = (int) ceil($this->pagination['num_items'] / $this->pagination['limit']);
     // num pages is always equal to at least 1
     if ($this->pagination['num_pages'] == 0) {
         $this->pagination['num_pages'] = 1;
     }
     // redirect if the request page doesn't exist
     if ($this->requestedPage > $this->pagination['num_pages'] || $this->requestedPage < 1) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // debug mode = no cache
     if (!SPOON_DEBUG) {
         // set cache content
         SpoonFile::setContent($this->cacheFile, "<?php\n" . '$pagination = ' . var_export($this->pagination, true) . ";\n" . '$items = ' . var_export($this->items, true) . ";\n?>");
     }
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:35,代码来源:autosuggest.php

示例13: buildCache


//.........这里部分代码省略.........
                        $treeType = 'redirect';
                    }
                    // direct action?
                    if (isset($data['is_action']) && $data['is_action']) {
                        $treeType = 'direct_action';
                    }
                }
                // add type
                $temp['tree_type'] = $treeType;
                // add it
                $navigation[$page['type']][$page['parent_id']][$pageID] = $temp;
            }
        }
        // order by URL
        asort($keys);
        // write the key-file
        $keysString = '<?php' . "\n\n";
        $keysString .= '/**' . "\n";
        $keysString .= ' * This file is generated by Fork CMS, it contains' . "\n";
        $keysString .= ' * the mapping between a pageID and the URL' . "\n";
        $keysString .= ' * ' . "\n";
        $keysString .= ' * Fork CMS' . "\n";
        $keysString .= ' * @generated	' . date('Y-m-d H:i:s') . "\n";
        $keysString .= ' */' . "\n\n";
        $keysString .= '// init var' . "\n";
        $keysString .= '$keys = array();' . "\n\n";
        // loop all keys
        foreach ($keys as $pageID => $URL) {
            $keysString .= '$keys[' . $pageID . '] = \'' . $URL . '\';' . "\n";
        }
        // end file
        $keysString .= "\n" . '?>';
        // write the file
        SpoonFile::setContent(FRONTEND_CACHE_PATH . '/navigation/keys_' . $language . '.php', $keysString);
        // write the navigation-file
        $navigationString = '<?php' . "\n\n";
        $navigationString .= '/**' . "\n";
        $navigationString .= ' * This file is generated by Fork CMS, it contains' . "\n";
        $navigationString .= ' * more information about the page-structure' . "\n";
        $navigationString .= ' * ' . "\n";
        $navigationString .= ' * Fork CMS' . "\n";
        $navigationString .= ' * @generated	' . date('Y-m-d H:i:s') . "\n";
        $navigationString .= ' */' . "\n\n";
        $navigationString .= '// init var' . "\n";
        $navigationString .= '$navigation = array();' . "\n\n";
        // loop all types
        foreach ($navigation as $type => $pages) {
            // loop all parents
            foreach ($pages as $parentID => $page) {
                // loop all pages
                foreach ($page as $pageID => $properties) {
                    // loop properties
                    foreach ($properties as $key => $value) {
                        // page_id should be an integer
                        if (is_int($value)) {
                            $line = '$navigation[\'' . $type . '\'][' . $parentID . '][' . $pageID . '][\'' . $key . '\'] = ' . $value . ';' . "\n";
                        } elseif (is_bool($value)) {
                            if ($value) {
                                $line = '$navigation[\'' . $type . '\'][' . $parentID . '][' . $pageID . '][\'' . $key . '\'] = true;' . "\n";
                            } else {
                                $line = '$navigation[\'' . $type . '\'][' . $parentID . '][' . $pageID . '][\'' . $key . '\'] = false;' . "\n";
                            }
                        } elseif ($key == 'extra_blocks') {
                            if ($value === null) {
                                $line = '$navigation[\'' . $type . '\'][' . $parentID . '][' . $pageID . '][\'' . $key . '\'] = null;' . "\n";
                            } else {
开发者ID:nickmancol,项目名称:forkcms-rhcloud,代码行数:67,代码来源:model.php

示例14: getData


//.........这里部分代码省略.........
         if (!isset($data['aggregates_total']) || $force) {
             $data['aggregates_total'] = BackendAnalyticsHelper::getAggregates(mktime(0, 0, 0, 1, 1, 2005), mktime(0, 0, 0));
         }
         // nothing in cache - fetch from google and set cache
         if (!isset($data['metrics_per_day']) || $force) {
             $data['metrics_per_day']['entries'] = BackendAnalyticsHelper::getMetricsPerDay($startTimestamp, $endTimestamp);
         }
         // traffic sources, top keywords and top referrals on index page
         if ($page == 'all' || $page == 'index') {
             // nothing in cache - fetch from google and set cache
             if (!isset($data['traffic_sources']) || $force) {
                 $data['traffic_sources']['entries'] = BackendAnalyticsHelper::getTrafficSourcesGrouped(array('pageviews'), $startTimestamp, $endTimestamp, 'pageviews');
             }
             // nothing in cache
             if (!isset($data['top_keywords']) || $force) {
                 // fetch from google and use a safe limit
                 $gaResults = BackendAnalyticsHelper::getKeywords('pageviews', $startTimestamp, $endTimestamp, 'pageviews', 50);
                 // set cache
                 $data['top_keywords']['entries'] = $gaResults['entries'];
             }
             // nothing in cache
             if (!isset($data['top_referrals']) || $force) {
                 // fetch from google and use a safe limit
                 $gaResults = BackendAnalyticsHelper::getReferrals('pageviews', $startTimestamp, $endTimestamp, 'pageviews', 50);
                 // init vars
                 $topReferrals = array();
                 // add entries to items
                 foreach ($gaResults['entries'] as $entry) {
                     $topReferrals[] = array('referrer' => $entry['source'] . $entry['referralPath'], 'pageviews' => $entry['pageviews']);
                 }
                 // set cache
                 $data['top_referrals']['entries'] = $topReferrals;
             }
         }
         // top pages on index and content page
         if ($page == 'all' || $page == 'index' || $page == 'content') {
             // nothing in cache
             if (!isset($data['top_pages']) || $force) {
                 // fetch from google and use a safe limit
                 $gaResults = BackendAnalyticsHelper::getPages('pageviews', $startTimestamp, $endTimestamp, 'pageviews', 50);
                 // set cache
                 $data['top_pages']['entries'] = $gaResults['entries'];
             }
         }
         // top exit pages on content page
         if ($page == 'all' || $page == 'content') {
             // nothing in cache
             if (!isset($data['top_exit_pages']) || $force) {
                 // fetch from google
                 $gaResults = BackendAnalyticsHelper::getPages(array('exits', 'pageviews'), $startTimestamp, $endTimestamp, 'exits', 50);
                 // set cache
                 $data['top_exit_pages']['entries'] = $gaResults['entries'];
             }
         }
         // top exit pages on all pages page
         if ($page == 'all' || $page == 'all_pages') {
             // nothing in cache
             if (!isset($data['pages']) || $force) {
                 // fetch from google
                 $gaResults = BackendAnalyticsHelper::getPages(array('bounces', 'entrances', 'exits', 'newVisits', 'pageviews', 'timeOnSite', 'visits'), $startTimestamp, $endTimestamp, 'pageviews', 50);
                 // set cache
                 $data['pages']['entries'] = $gaResults['entries'];
                 $data['pages']['attributes'] = array('totalResults' => $gaResults['totalResults']);
             }
         }
         // exit pages on exit pages page
         if ($page == 'all' || $page == 'exit_pages') {
             // nothing in cache
             if (!isset($data['exit_pages']) || $force) {
                 // fetch from google
                 $gaResults = BackendAnalyticsHelper::getExitPages(array('bounces', 'entrances', 'exits', 'newVisits', 'pageviews', 'timeOnSite', 'visits'), $startTimestamp, $endTimestamp, 'exits', 50);
                 // set cache
                 $data['exit_pages']['entries'] = $gaResults['entries'];
             }
         }
         // detail page
         if ($page == 'detail_page') {
             // nothing in cache
             if (!isset($data['page' . $pageId]) || $force) {
                 // fetch from google
                 $gaResults = BackendAnalyticsHelper::getDataForPage($pageId, $startTimestamp, $endTimestamp);
                 // set cache
                 $data['page_' . $pageId] = $gaResults;
             }
         }
         // update cache file
         BackendAnalyticsModel::writeCacheFile($data, $startTimestamp, $endTimestamp);
     } catch (Exception $e) {
         // set file content to indicate something went wrong if needed
         if (isset($filename)) {
             SpoonFile::setContent($filename, 'error');
         } else {
             throw new SpoonException('Something went wrong while getting data.');
         }
     }
     // remove temporary file if needed
     if (isset($filename)) {
         SpoonFile::setContent($filename, 'done');
     }
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:101,代码来源:get_data.php

示例15: uniqid

 }
 if (!in_array($frm->getField('blood')->getValue(), array('', 'O+', 'A+', 'B+', 'AB+', 'O-', 'A-', 'B-', 'AB-'))) {
     $frm->getField('blood')->setError('Please choose from the list only!');
 }
 if ($frm->getField('height')->isFilled()) {
     $frm->getField('height')->isNumeric('Digits only please! eg: 180');
     //it needs to be numeric!
 }
 if ($frm->getField('weight')->isFilled()) {
     $frm->getField('weight')->isNumeric('Digits only please! eg: 80');
     //it needs to be numeric!
 }
 if ($frm->isCorrect()) {
     if ($frm->getField('photo')->isFilled()) {
         $imagename = uniqid();
         SpoonFile::setContent(IMAGE_PATH . '/' . $imagename . '.' . $frm->getField('photo')->getExtension(), SpoonFile::getContent($frm->getField('photo')->getTempFileName()));
         //create Thumbnail
         $frm->getField('photo')->createThumbnail(IMAGE_PATH . '/' . $imagename . '_thumbnail.' . $frm->getField('photo')->getExtension(), 130, 130);
     }
     $company = "";
     for ($i = 1; $i < 6; $i++) {
         $company .= $frm->getField('company' . $i)->getValue() . ', ' . $frm->getField('registerno' . $i)->getValue() . ', ' . $frm->getField('companyno' . $i)->getValue() . ', ' . $frm->getField('companyemail' . $i)->getValue() . ', ' . $frm->getField('shareholder' . $i)->getValue() . ', ' . $frm->getField('registeraddr' . $i)->getValue() . ', ' . $frm->getField('businessaddr' . $i)->getValue();
         if ($i < 6) {
             $company .= ', ';
         }
     }
     //get values from form
     $values = array();
     for ($i = 1; $i < 6; $i++) {
         $values = array_merge($values, array('company' . $i, 'shareholder' . $i, 'registerno' . $i, 'companyno' . $i, 'companyemail' . $i, 'registeraddr' . $i, 'businessaddr' . $i));
     }
开发者ID:jincongho,项目名称:clienthub,代码行数:31,代码来源:index.php


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