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


PHP modX::getChunk方法代码示例

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


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

示例1: fileUpload

 /**
  * Upload file
  *
  * @param $data
  * @param string $class
  *
  * @return array|string
  */
 public function fileUpload($data)
 {
     if (!$this->authenticated) {
         return $this->error('ms2galleryform_err_access_denied');
     }
     /** @var modProcessorResponse $response */
     $response = $this->modx->runProcessor('web/gallery/upload', $data, array('processors_path' => $this->config['corePath'] . 'processors/'));
     if ($response->isError()) {
         return $this->error($response->getMessage());
     }
     $file = $response->getObject();
     $file['size'] = round($file['properties']['size'] / 1024, 2);
     $tpl = $file['type'] == 'image' ? $this->config['tplImage'] : $this->config['tplFile'];
     $html = $this->modx->getChunk($tpl, $file);
     return $this->success('', $html);
 }
开发者ID:bendasvadim,项目名称:ms2GalleryForm,代码行数:24,代码来源:ms2galleryform.class.php

示例2: uploadFile

 /**
  * Main processing method
  *
  * @param $data
  *
  * @return string
  */
 public function uploadFile($data)
 {
     if (!$this->checkAuth()) {
         return 'Wrong auth';
     }
     $fileParts = pathinfo($data['name']);
     $data['extension'] = strtolower($fileParts['extension']);
     // Main verifications
     if (!($file = is_uploaded_file($data['tmp_name']))) {
         return $this->failure('uf_err_nofile');
     } else {
         if (!in_array($data['extension'], $this->config['fileExtensions'])) {
             return $this->failure('uf_err_extension');
         } else {
             if ($data['size'] > $this->config['maxFilesize']) {
                 return $this->failure('uf_err_size');
             }
         }
     }
     // Save image
     $base_url = $this->modx->getOption('url_scheme', null, 'http://', true);
     $base_url .= $this->modx->getOption('http_host');
     if (in_array($data['extension'], $this->config['imageExtensions'])) {
         if ($file = $this->saveImage($data)) {
             $arr = array('image' => strpos($file['image'], '://') === false ? $base_url . '/' . ltrim($file['image'], '/') : $file['image'], 'thumb' => !empty($file['thumb']) ? strpos($file['thumb'], '://') === false ? $base_url . '/' . ltrim($file['thumb'], '/') : $file['thumb'] : '');
             return $this->success($this->modx->getChunk($this->config['tplImage'], $arr));
         }
     } else {
         if ($file = $this->saveFile($data)) {
             $arr = array('file' => strpos($file['file'], '://') === false ? $base_url . '/' . ltrim($file['file'], '/') : $file['file']);
             return $this->success($this->modx->getChunk($this->config['tplFile'], $arr));
         }
     }
     return $this->failure('uf_err_unknown');
 }
开发者ID:bendasvadim,项目名称:modx-uploadify,代码行数:42,代码来源:uploadify.class.php

示例3: add

 /**
  * Add an element to the list
  *
  * @param integer $docId
  * @return bool|integer
  */
 private function add($docId)
 {
     $found = 0;
     $newElement = array();
     $newElement['rememberId'] = $docId;
     if (!$this->getOption('packagename')) {
         // no packagename -> resource
         $resource = $this->modx->getObject('modResource', array('id' => $docId));
         $tvs = array();
         $templateVars =& $resource->getMany('TemplateVars');
         foreach ($templateVars as $templateVar) {
             $tvs[$this->getOption('tvPrefix') . $templateVar->get('name')] = $templateVar->renderOutput($resource->get('id'));
         }
         $row = array_merge($resource->toArray(), $tvs);
     } else {
         $packagepath = $this->modx->getOption('core_path') . 'components/' . $this->getOption('packagename') . '/';
         $modelpath = $packagepath . 'model/';
         $this->modx->addPackage($this->getOption('packagename'), $modelpath);
         $resource = $this->modx->getObject($this->getOption('classname'), array($this->getOption('keyname') => $docId));
         if ($resource) {
             $joinvalues = array();
             $joinoption = $this->getOption('joins');
             if ($joinoption) {
                 foreach ($joinoption as $join) {
                     $values = $resource->getOne($join);
                     $joinvalues[$join] = $values->toArray();
                 }
             }
             $row = array_merge($joinvalues, $resource->toArray());
         } else {
             $this->modx->log(xPDO::LOG_LEVEL_ERROR, 'Could not retreive an object with key "' . $this->getOption('keyname') . '" and value "' . $docId . '"', '', 'RememberThis');
             return false;
         }
     }
     $newElement['identifier'] = $row[$this->getOption('keyname')];
     $newElement['itemtitle'] = $this->modx->getChunk($this->getOption('itemTitleTpl'), $row);
     foreach ($_SESSION['rememberThis'] as &$element) {
         if (!count(array_diff_assoc($element['element'], $newElement))) {
             $found = 1;
         }
     }
     if (!$found) {
         $_SESSION['rememberThis'][] = array('element' => $newElement);
         if ($this->getOption('useCookie')) {
             $this->setCookie();
         }
         return key($_SESSION['rememberThis']);
     } else {
         return false;
     }
 }
开发者ID:Vitaliz,项目名称:RememberThis,代码行数:57,代码来源:rememberthis.class.php

示例4: getTemplateChunk

 /**
  * Get a template chunk. All chunks retrieved by this function are
  * cached in $modx->chunkieCache for later reusage.
  *
  * @access public
  * @param string $tpl The name of a MODX chunk (could be prefixed by
  * @FILE, @CODE or @CHUNK). Chunknames starting with '@FILE' are
  * loading a chunk from the filesystem (prefixed by $basepath).
  * Chunknames starting with '@CODE' contain the template code itself.
  * @return string The template chunk.
  */
 public function getTemplateChunk($tpl)
 {
     switch (TRUE) {
         case substr($tpl, 0, 5) == '@FILE':
             $filename = trim(substr($tpl, 5), ' :');
             if (!isset($this->modx->chunkieCache['@FILE'])) {
                 $this->modx->chunkieCache['@FILE'] = array();
             }
             if (!empty($filename) && !array_key_exists($filename, $this->modx->chunkieCache['@FILE'])) {
                 if (file_exists($this->options['basepath'] . $filename)) {
                     $template = file_get_contents($this->options['basepath'] . $filename);
                 } else {
                     $template = '';
                 }
                 $this->modx->chunkieCache['@FILE'][$filename] = $template;
             } else {
                 $template = !empty($filename) ? $this->modx->chunkieCache['@FILE'][$filename] : '';
             }
             break;
         case substr($tpl, 0, 5) == '@CODE':
             $template = trim(substr($tpl, 5), ' :');
             break;
         default:
             if (substr($tpl, 0, 6) == '@CHUNK') {
                 $chunkname = trim(substr($tpl, 6), ' :');
             } else {
                 $chunkname = $tpl;
             }
             if (!isset($this->modx->chunkieCache['@CHUNK'])) {
                 $this->modx->chunkieCache['@CHUNK'] = array();
             }
             if (!empty($chunkname) && !array_key_exists($chunkname, $this->modx->chunkieCache['@CHUNK'])) {
                 $chunk = $this->modx->getChunk($chunkname);
                 $template = $chunk ? $chunk : $chunkname;
                 $this->modx->chunkieCache['@CHUNK'][$chunkname] = $template;
             } else {
                 $template = !empty($chunkname) ? $this->modx->chunkieCache['@CHUNK'][$chunkname] : '';
             }
             break;
     }
     return $template;
 }
开发者ID:AlexeyMur,项目名称:WebLoginPE,代码行数:53,代码来源:newchunkie.class.php

示例5: getRssCall

    /**
     * Get the call for the RSS feed
     * @return string
     */
    public function getRssCall()
    {
        $settings = $this->getContainerSettings();
        $content = '[[!getArchives?
          &pageVarKey=`page`
          &parents=`' . $this->get('id') . '`
          &where=`{"class_key":"Article","searchable":1}`
          &limit=`' . $this->xpdo->getOption('rssItems', $settings, 10) . '`
          &showHidden=`1`
          &includeContent=`1`
          &includeTVs=`1`
          &processTVs=`1`
          &sortby=`' . $this->xpdo->getOption('sortBy', $settings, 'publishedon') . '`
          &sortdir=`' . $this->xpdo->getOption('sortDir', $settings, 'DESC') . '`

          &tagKey=`articlestags`
          &tagSearchType=`contains`
          &makeArchive=`0`
          &cache=`0`
          &tpl=`' . $this->xpdo->getOption('tplRssItem', $settings, 'sample.ArticlesRssItem') . '`
        ]]';
        $content = $this->xpdo->getChunk($this->xpdo->getOption('tplRssFeed', $settings, 'sample.ArticlesRss'), array('content' => $content, 'year' => date('Y')));
        return $content;
    }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:28,代码来源:articlescontainer.class.php

示例6: processBindings

 /**
  * Process bindings assigned to a template variable.
  *
  * @access public
  * @param string $value The value specified from the binding.
  * @param integer $resourceId The resource in which the TV is assigned.
  * @param boolean $preProcess Whether or not to process certain bindings.
  * @return string The processed value.
  */
 public function processBindings($value = '', $resourceId = 0, $preProcess = true)
 {
     $bdata = $this->getBindingDataFromValue($value);
     if (empty($bdata['cmd'])) {
         return $value;
     }
     $modx =& $this->xpdo;
     if (empty($modx->resource)) {
         if (!empty($resourceId)) {
             $modx->resource = $modx->getObject('modResource', $resourceId);
         }
         if (empty($modx->resource) || empty($resourceId)) {
             $modx->resource = $modx->newObject('modResource');
             $modx->resource->set('id', 0);
         }
     }
     $cmd = $bdata['cmd'];
     $param = !empty($bdata['param']) ? $bdata['param'] : null;
     switch ($cmd) {
         case 'FILE':
             if ($preProcess) {
                 $output = $this->processFileBinding($param);
             }
             break;
         case 'CHUNK':
             /* retrieve a chunk and process it's content */
             if ($preProcess) {
                 $output = $this->xpdo->getChunk($param);
             }
             break;
         case 'RESOURCE':
         case 'DOCUMENT':
             /* retrieve a document and process it's content */
             if ($preProcess) {
                 $query = $this->xpdo->newQuery('modResource', array('id' => (int) $param, 'deleted' => false));
                 $query->select('content');
                 if ($query->prepare() && $query->stmt->execute()) {
                     $output = $query->stmt->fetch(PDO::FETCH_COLUMN);
                 } else {
                     $output = 'Unable to locate resource ' . $param;
                 }
             }
             break;
         case 'SELECT':
             /* selects a record from the cms database */
             if ($preProcess) {
                 $dbtags = array();
                 if ($modx->resource && $modx->resource instanceof modResource) {
                     $dbtags = $modx->resource->toArray();
                 }
                 $dbtags['DBASE'] = $this->xpdo->getOption('dbname');
                 $dbtags['PREFIX'] = $this->xpdo->getOption('table_prefix');
                 foreach ($dbtags as $key => $pValue) {
                     $param = str_replace('[[+' . $key . ']]', $pValue, $param);
                 }
                 $stmt = $this->xpdo->query('SELECT ' . $param);
                 if ($stmt && $stmt instanceof PDOStatement) {
                     $data = '';
                     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
                         $col = '';
                         if (isset($row[1])) {
                             $col = $row[0] . '==' . $row[1];
                         } else {
                             $col = $row[0];
                         }
                         $data .= (!empty($data) ? '||' : '') . $col;
                     }
                     $stmt->closeCursor();
                 }
                 $output = $data;
             }
             break;
         case 'EVAL':
             /* evaluates text as php codes return the results */
             if ($preProcess) {
                 $output = eval($param);
             }
             break;
         case 'INHERIT':
             if ($preProcess) {
                 $output = $this->processInheritBinding($param, $resourceId);
             } else {
                 $output = $value;
             }
             break;
         case 'DIRECTORY':
             $path = $this->xpdo->getOption('base_path') . $param;
             if (substr($path, -1, 1) != '/') {
                 $path .= '/';
             }
             if (!is_dir($path)) {
//.........这里部分代码省略.........
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:101,代码来源:modtemplatevar.class.php

示例7: getWrapper

 /** @inheritdoc} */
 public function getWrapper()
 {
     return $this->modx->getChunk($this->config['tplOuter'], $this->config);
 }
开发者ID:vgrish,项目名称:ecc,代码行数:5,代码来源:eccbasecontroller.class.php

示例8: dirname

<?php

//initialise MODx
require_once dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . "/config.core.php";
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('web');
//or mgr or any content you like
$modx->getService('error', 'error.modError', '', '');
$roxy = $modx->getChunk('roxyConfJson');
$file = MODX_ASSETS_PATH . 'components/tinymcewrapper/roxy/fileman/conf.json';
$fileExistingCode = file_get_contents($file);
if ($fileExistingCode) {
    if (!strpos($fileExistingCode, $roxy)) {
        $myfile = fopen($file, "w") or die("Unable to open file!");
        fwrite($myfile, $roxy);
        fclose($myfile);
    }
}
?>
<!DOCTYPE html>
<html>
<head>
<!--
  RoxyFileman - web based file manager. Ready to use with CKEditor, TinyMCE. 
  Can be easily integrated with any other WYSIWYG editor or CMS.

  Copyright (C) 2013, RoxyFileman.com - Lyubomir Arsov. All rights reserved.
  For licensing, see LICENSE.txt or http://RoxyFileman.com/license

  This program is free software: you can redistribute it and/or modify
开发者ID:kipps,项目名称:sri-lanka,代码行数:31,代码来源:roxy.php

示例9: array

         $user->save();
         //Based on code from culd | steffan
         $uid = $user->get('id');
         $userProfile = $modx->newObject('modUserProfile');
         $userProfile->fromArray(array('internalKey' => $uid, 'fullname' => $sFirstName . ' ' . $sLastName, 'email' => $sEmail));
         $success = $user->addOne($userProfile);
         //Adds profile to created user
         if ($success) {
             $sAddLog .= $user->get('username') . ' added <br />';
             $iAddCount++;
             $sGroup == 'Administrator' ? $iRoleId = 2 : ($iRoleId = 1);
             $user->joinGroup($sGroup, $iRoleId);
             //Adds user to Group
             $user->save();
             $userProfile->save();
             $sMessage = $modx->getChunk($sEmailChunkName, array('alias' => $sAlias, 'password' => $sPass, 'sname' => $modx->getOption('site_name'), 'surl' => $modx->getOption('url_scheme') . $modx->getOption('http_host')));
             $user->sendEmail($sMessage);
         } else {
             $modx->log(modX::LOG_LEVEL_INFO, 'Failed to add ' . $sAlias . '.');
         }
     }
 }
 $user = $modx->getObject('modUser', array('username' => $sAdminUsername));
 $sMessageAdmin = $modx->getChunk($sEmailAdminChunkName, array('addCount' => $iAddCount, 'changeCount' => $iChangeCount, 'addLog' => $sAddLog, 'changeLog' => $sChangeLog));
 $modx->getService('mail', 'mail.modPHPMailer');
 $modx->mail->set(modMail::MAIL_BODY, $sMessageAdmin);
 $modx->mail->set(modMail::MAIL_FROM, $modx->config['emailsender']);
 $modx->mail->set(modMail::MAIL_FROM_NAME, $modx->config['site_name']);
 $modx->mail->set(modMail::MAIL_SENDER, $modx->config['emailsender']);
 $modx->mail->set(modMail::MAIL_SUBJECT, 'ImportUsersX import results');
 $modx->mail->setHTML(true);
开发者ID:rtripault,项目名称:ImportUsersX,代码行数:31,代码来源:import.php


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