コード例 #1
0
 public function duplicate($strNewName = "")
 {
     global $objLang, $_CONF;
     if ($this->id > 0) {
         //*** Cache the name of the current element.
         $strName = $this->name;
         if (!empty($strNewName)) {
             //*** Set the name of the duplicate element.
             $this->name = sprintf($strNewName, $strName);
         }
         //*** Duplicate the element.
         $objReturn = parent::duplicate();
         if (class_exists("AuditLog")) {
             AuditLog::addLog(AUDIT_TYPE_STORAGE, $this->getId(), $strName, "duplicate", $objReturn->getId());
         }
         if (class_exists("AuditLog")) {
             AuditLog::addLog(AUDIT_TYPE_STORAGE, $objReturn->getId(), $objReturn->getName(), "create");
         }
         //*** Reset the name of the current element.
         $this->name = $strName;
         //*** Copy any child elements to the duplicate.
         $strSql = sprintf("SELECT * FROM pcms_storage_item WHERE parentId = '%s' AND accountId = '%s'", $this->id, $_CONF['app']['account']->getId());
         $objElements = StorageItem::select($strSql);
         foreach ($objElements as $objElement) {
             $objElement->copy($objReturn->getId());
         }
         return $objReturn;
     }
     return NULL;
 }
コード例 #2
0
 public static function getFileListHTML()
 {
     global $_CONF;
     $strReturn = "";
     $intParentId = request("parentId", 0);
     $intAccountId = $_CONF['app']['account']->getId();
     $arrImages = array('jpg', 'jpeg', 'gif', 'png');
     $strSql = sprintf("SELECT * FROM pcms_storage_item WHERE parentId = '%s' AND typeId IN (%s) AND accountId = '%s' ORDER BY name", $intParentId, STORAGE_TYPE_FILE, $intAccountId);
     $objElements = StorageItem::select($strSql);
     $strReturn .= "<field id=\"{$intParentId}\"><![CDATA[";
     $strReturn .= "<ul>";
     foreach ($objElements as $objElement) {
         $objData = $objElement->getData();
         $strExtension = substr(strrchr($objData->getLocalName(), '.'), 1);
         $strImageSrc = in_array($strExtension, $arrImages) ? Setting::getValueByName("web_server") . Setting::getValueByName("file_folder") . $objData->getLocalName() : "/images/ico_document_big.gif";
         $strReturn .= "<li><a href=\"\" id=\"eid_{$objElement->getId()}\"><img width=\"100\" height=\"100\" src=\"{$strImageSrc}\" alt=\"{$objData->getLocalName()}\" /></a><span>" . str_replace("&", "&amp;", $objElement->getName()) . "</span></li>";
     }
     $strReturn .= "</ul>";
     $strReturn .= "]]></field>";
     return $strReturn;
 }