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


PHP FileHelper::getSubElements方法代码示例

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


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

示例1: run_build_backend

function run_build_backend($task, $args)
{
    ini_set("memory_limit", "2048M");
    // get configuration
    // define constants
    define('SF_ROOT_DIR', sfConfig::get('sf_root_dir'));
    define('SF_APP', 'backend');
    define('SF_ENVIRONMENT', 'prod');
    define('SF_DEBUG', false);
    require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
    //	$databaseManager = new sfDatabaseManager();
    //	$databaseManager->initialize();
    if (!class_exists("XMLParser")) {
        include sfConfig::get('sf_root_dir') . "/lib/tools/XMLParser.class.php";
    }
    if (!class_exists("FileHelper")) {
        include sfConfig::get('sf_root_dir') . "/lib/helper/FileHelper.php";
    }
    $modules = FileHelper::getSubElements(sfConfig::get('sf_root_dir') . "/apps/" . SF_APP . "/modules", "folder");
    $content = "function initBindings()\n{\n";
    $contentTemplate = "";
    echo_cms_title("Building backend...");
    foreach ($modules as $module => $path) {
        if ($module == "admin") {
            $module = "tag";
        }
        if (substr($module, 0, 1) == ".") {
            continue;
        }
        $objects1 = array();
        $objects2 = array();
        $objectsDone = array();
        if (!is_readable($path . "/config/leftTree.xml") && !is_readable($path . "/config/mainList.xml")) {
            continue;
        } else {
            $objects1 = XMLParser::getXMLdataValues($path . "/config/leftTree.xml");
            $objects2 = XMLParser::getXMLdataValues($path . "/config/mainList.xml");
        }
        $objects = array_merge($objects1, $objects2);
        $content .= "\n/*------------- MODULE " . $module . " ----------------*/\n\n";
        $contentTemplate .= "\n<!-- -------------------- MODULE " . $module . " -------------------- -->\n\n";
        $contentTemplate .= "<?php if(\$userRights['{$module}']): ?>\n";
        echo_cms_sep();
        echo_cms("Module " . $module);
        echo_cms_sep();
        foreach ($objects as $obj) {
            $createCommands = "";
            $contentTemplateLiTags = "";
            $forbidenGenericCommands = array();
            if ($obj['tag'] == 'OBJECT' && $obj['type'] == 'complete') {
                $objName = $obj['value'];
                if (in_array($objName, $objectsDone)) {
                    continue;
                }
                $objectsDone[] = $objName;
                echo_cms(" Writing commands for : " . $objName);
                $params = $obj['attributes']['COMMANDS'];
                if ($params) {
                    $commands = explode(",", $params);
                    foreach ($commands as $command) {
                        if (substr($command, 0, 1) == "-") {
                            $forbidenGenericCommands[] = substr($command, 1);
                        } else {
                            $docType = substr($command, 6);
                            $commandTitle = $docType;
                            if (substr($docType, -4) == "I18n") {
                                $commandTitle = substr($docType, 0, -4) . " (Language version)";
                            }
                            $createCommands .= "\t\t\t'" . $command . "': function(t) {createDocument('" . $docType . "', t.id);},\n";
                            $contentTemplateLiTags .= "\t\t\t<?php if(\$userRights['{$module}']['{$objName}']['{$command}']): ?>\n";
                            $contentTemplateLiTags .= "\t\t\t\t<li id='" . $command . "'><img src='/images/icons/" . strtolower($docType) . ".png'/>Create " . ucfirst($commandTitle) . "</li>\n";
                            $contentTemplateLiTags .= "\t\t\t<?php endif; ?>\n";
                        }
                    }
                }
                if ($objName != "Rootfolder") {
                    if (!in_array("delete", $forbidenGenericCommands)) {
                        $createCommands .= "\t\t\t'deleteDocument': function(t) {deleteDocument(t.id);},\n";
                        $contentTemplateLiTags .= "\t\t\t<?php if(\$userRights['{$module}']['{$objName}']['delete']): ?>\n";
                        $contentTemplateLiTags .= "\t\t\t\t<li id='deleteDocument'><img src='/images/icons/delete_document.png'/>Delete</li>\n";
                        $contentTemplateLiTags .= "\t\t\t<?php endif; ?>\n";
                    }
                    if (!in_array("edit", $forbidenGenericCommands)) {
                        $createCommands .= "\t\t\t'editDocument': function(t) {editDocument('" . $objName . "', t.id);},\n";
                        $contentTemplateLiTags .= "\t\t\t<?php if(\$userRights['{$module}']['{$objName}']['edit']): ?>\n";
                        $contentTemplateLiTags .= "\t\t\t\t<li id='editDocument'><img src='/images/icons/edit_document.png'/>Edit</li>\n";
                        $contentTemplateLiTags .= "\t\t\t<?php endif; ?>\n";
                    }
                    if (!in_array("order", $forbidenGenericCommands)) {
                        $createCommands .= "\t\t\t'orderDocumentUp': function(t) {orderDocument(t.id,true);},\n";
                        $createCommands .= "\t\t\t'orderDocumentDown': function(t) {orderDocument(t.id,false);},\n";
                        $contentTemplateLiTags .= "\t\t\t<?php if(\$userRights['{$module}']['{$objName}']['order']): ?>\n";
                        $contentTemplateLiTags .= "\t\t\t\t<li id='orderDocumentUp'><img src='/images/icons/arrow_up.png'/>Move Up</li>\n";
                        $contentTemplateLiTags .= "\t\t\t\t<li id='orderDocumentDown'><img src='/images/icons/arrow_down.png'/>Move Down</li>\n";
                        $contentTemplateLiTags .= "\t\t\t<?php endif; ?>\n";
                    }
                }
                $createCommands = substr($createCommands, 0, -2) . "\n";
                $contentTemplate .= "\t<?php if(\$userRights['{$module}']['{$objName}']): ?>\n";
                $contentTemplate .= "\t<div class='contextMenu' id='" . $module . "_" . strtolower($objName) . "'>\n\t<ul>\n";
//.........这里部分代码省略.........
开发者ID:kotow,项目名称:work,代码行数:101,代码来源:sfPakeMisc.php

示例2: executeSavePageContent

 public function executeSavePageContent()
 {
     $this->page = Document::getDocumentInstance($this->getRequestParameter('id'));
     $content = '<?xml version="1.0" encoding="UTF-8"?>';
     $content .= '<blocks>';
     $data = $this->page->getContent();
     if (!empty($data)) {
         $blockContentsTags = XMLParser::getXMLdataValues($data, false, false);
     }
     foreach ($blockContentsTags as $block) {
         if ($block["tag"] == "BLOCK") {
             $content .= '<block id="' . $block['attributes']["ID"] . '" target="' . $block['attributes']["TARGET"] . '" action="' . $block['attributes']["ACTION"] . '"';
             if (isset($block['attributes']["PARAMETERS"])) {
                 $content .= ' parameters="' . $block['attributes']["PARAMETERS"] . '"';
             }
             $content .= '>';
             if ($this->getRequestParameter($block['attributes']["ID"])) {
                 $blockContent = $this->getRequestParameter($block['attributes']["ID"]);
                 if (substr($block['attributes']["ID"], 0, 8) == "richtext") {
                     $imgTags = explode('<img', $blockContent);
                     $imageFound = false;
                     $thumbDir = "richtext/" . $this->getRequestParameter('id') . "/" . substr($block['attributes']["ID"], 8);
                     $usedImg = array();
                     for ($i = 0; $i < count($imgTags); $i++) {
                         $imgParams = explode('/>', $imgTags[$i]);
                         $id = 0;
                         $thumb = "richtext";
                         foreach ($imgParams as $paramStr) {
                             $width = null;
                             $height = null;
                             $id = false;
                             if (strstr($paramStr, "width")) {
                                 $width = strstr($paramStr, "width");
                                 $width = substr($width, 7);
                                 $pos = strpos($width, '"');
                                 $width = substr($width, 0, $pos);
                             }
                             if (strstr($paramStr, "height")) {
                                 $height = strstr($paramStr, "height");
                                 $height = substr($height, 8);
                                 $pos = strpos($height, '"');
                                 $height = substr($height, 0, $pos);
                             }
                             if (strstr($paramStr, "id")) {
                                 $id = strstr($paramStr, "id");
                                 $id = substr($id, 4);
                                 $pos = strpos($id, '"');
                                 $id = substr($id, 0, $pos);
                             }
                             if ($id) {
                                 $prefix = time();
                                 if (strstr($paramStr, "src")) {
                                     $src = strstr($paramStr, "src");
                                     $src = substr($src, 5);
                                     $pos = strpos($src, '"');
                                     $src = substr($src, 0, $pos);
                                     $parts = explode("/", $src);
                                     if ($parts[6]) {
                                         $prefix = $parts[6];
                                     }
                                 }
                                 $img = Document::getDocumentInstance($id);
                                 if ($img && get_class($img) == "Media" && $img->isImage()) {
                                     if (empty($height) && empty($width)) {
                                         list($width, $height) = getimagesize($img->getServerAbsoluteUrl());
                                     }
                                     $img->resizeImage($thumbDir, $height, $width, $prefix);
                                     $imageFound = true;
                                     $usedImg[] = SF_ROOT_DIR . "/www/media/upload/thumbs/" . $thumbDir . "/" . $id . "-" . $prefix . "." . $img->getExtention();
                                 }
                             }
                             $id++;
                         }
                         $thumb = str_replace("/", "-", $thumbDir);
                         $replaceStr = 'src="/media/display/thumb/' . $thumb . '/freeimg/' . $prefix . '/id/';
                         $find = array('src="/media/display/id/', 'src="/media/display/thumb/thumbs/id/');
                         $replace = array($replaceStr, $replaceStr);
                         $blockParts[] = str_replace($find, $replace, $imgTags[$i]);
                     }
                     if ($imageFound) {
                         $blockContent = implode("<img ", $blockParts);
                     }
                     $blockContent = preg_replace('@(<[ \\n\\r\\t]*script(>|[^>]*>))@i', '', $blockContent);
                     $blockContent = preg_replace('@(<[ \\n\\r\\t]*/[ \\n\\r\\t]*script(>|[^>]*>))@i', '', $blockContent);
                     $files = FileHelper::getSubElements(SF_ROOT_DIR . "/www/media/upload/thumbs/" . $thumbDir, "file");
                     foreach ($files as $file) {
                         if (!in_array($file, $usedImg)) {
                             // delete RICHTEXT media
                             unlink($file);
                             // delete ORIGINAL media
                             $parts = explode(DIRECTORY_SEPARATOR, $file);
                             $delFile = array_pop($parts);
                             $delIdArr = explode("-", $delFile);
                             $delId = $delIdArr[0];
                             $imageToDelete = Document::getDocumentInstance($delId);
                             if ($imageToDelete) {
                                 $imageToDelete->delete();
                             }
                         }
                     }
//.........这里部分代码省略.........
开发者ID:kotow,项目名称:work,代码行数:101,代码来源:actions.class.php


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