コード例 #1
0
ファイル: Ajax.php プロジェクト: projectesIF/Sirius
    /**
     * make the permalink from the title
     *
     * @author Erik Spaan
     * @param 'title'   int the story id
     * @return string HTML string
     */
    public function updatepermalink()
    {
        $this->checkAjaxToken();
        $title = $this->request->getPost()->get('title', '');

        // define the lowercase permalink, using the title as slug, if not present
        //    if (!isset($args['urltitle']) || empty($args['urltitle'])) {
        //        $args['urltitle'] = strtolower(DataUtil::formatPermalink($args['title']));
        //    }
        // Construct the lowercase permalink, using the title as slug
        $permalink = strtolower(DataUtil::formatPermalink($title));

        return new Zikula_Response_Ajax(array('result' => $permalink));
    }
コード例 #2
0
ファイル: Admin.php プロジェクト: projectesIF/Sirius
    /**
     * Purge the permalink fields in the Feeds table
     * @return bool true on success, false on failure
     */
    public function purgepermalinks($args)
    {
        // Security check
        if (!SecurityUtil::checkPermission('Feeds::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }

        // disable categorization to do this (if enabled)
        $catenabled = ModUtil::getVar('Feeds', 'enablecategorization');
        if ($catenabled) {
            ModUtil::setVar('Feeds', 'enablecategorization', false);
            ModUtil::dbInfoLoad('Feeds', 'Feeds', true);
        }

        // get all the ID and permalink of the table
        $data = DBUtil::selectObjectArray('feeds', '', '', -1, -1, 'fid', null, null, array('fid', 'urltitle'));

        // loop the data searching for non equal permalinks
        $perma = '';
        foreach (array_keys($data) as $fid) {
            $perma = strtolower(DataUtil::formatPermalink($data[$fid]['urltitle']));
            if ($data[$fid]['urltitle'] != $perma) {
                $data[$fid]['urltitle'] = $perma;
            } else {
                unset($data[$fid]);
            }
        }

        // restore the categorization if was enabled
        if ($catenabled) {
            ModUtil::setVar('Feeds', 'enablecategorization', true);
        }

        if (empty($data)) {
            return true;
            // store the modified permalinks
        } elseif (DBUtil::updateObjectArray($data, 'feeds', 'fid')) {
            // Let the calling process know that we have finished successfully
            return true;
        } else {
            return false;
        }
    }
コード例 #3
0
ファイル: Admin.php プロジェクト: projectesIF/Sirius
    /**
     * Create the dud.
     * 
     * Parameters passed via the $args array or via a POST:
     * ----------------------------------------------------
     * string  label         The name of the item to be created.
     * string  attributename The attribute name of the item to be created.
     * numeric required      0 if not required, 1 if required.
     * numeric viewby        Viewable-by option; 0 thru 3, everyone, registered users, admins and account owners, admin only.
     * numeric displaytype   Display type; 0 thru 7.
     * array   listoptions   If the display type is a list, then the options to display in the list.
     * string  note          Note for the item.
     *
     * @param array $args All parameters passed to this function via an internal call.
     * 
     * @return bool True if item created, false otherwise.
     *
     * @see    Profile_admin_new()
     */
    public function create($args)
    {
		$this->checkCsrfToken();

        // Security check
        if (!SecurityUtil::checkPermission('Profile::', '::', ACCESS_ADD)) {
            return LogUtil::registerPermissionError();
        }

        // Get parameters from whatever input we need.
        $label       = isset($args['label'])         ? $args['label']         : $this->request->getPost()->get('label', null);
        $attrname    = isset($args['attributename']) ? $args['attributename'] : $this->request->getPost()->get('attributename', null);
        $required    = isset($args['required'])      ? $args['required']      : $this->request->getPost()->get('required', null);
        $viewby      = isset($args['viewby'])        ? $args['viewby']        : $this->request->getPost()->get('viewby', null);
        $displaytype = isset($args['displaytype'])   ? $args['displaytype']   : $this->request->getPost()->get('displaytype', null);
        $listoptions = isset($args['listoptions'])   ? $args['listoptions']   : $this->request->getPost()->get('listoptions', null);
        $note        = isset($args['note'])          ? $args['note']          : $this->request->getPost()->get('note', null);

        $returnurl = ModUtil::url('Profile', 'admin', 'view');

        // Validates and check if empty or already existing...
        if (empty($label)) {
            return LogUtil::registerError($this->__("Error! The personal info item must have a label. An example of a recommended label is: '_MYDUDLABEL'."), null, $returnurl);
        }

        if (empty($attrname)) {
            return LogUtil::registerError($this->__("Error! The personal info item must have an attribute name. An example of an acceptable name is: 'mydudfield'."), null, $returnurl);
        }

        if (ModUtil::apiFunc('Profile', 'user', 'get', array('proplabel' => $label))) {
            return LogUtil::registerError($this->__('Error! There is already an personal info item label with this naming.'), null, $returnurl);
        }

        if (ModUtil::apiFunc('Profile', 'user', 'get', array('propattribute' => $attrname))) {
            return LogUtil::registerError($this->__('Error! There is already an attribute name with this naming.'), null, $returnurl);
        }

        $permalinkssep = System::getVar('shorturlsseparator');
        $filteredlabel = str_replace($permalinkssep, '', DataUtil::formatPermalink($label));
        if ($label != $filteredlabel) {
            LogUtil::registerStatus($this->__('Warning! The personal info item label has been accepted, but was filtered and altered to ensure it contains no special characters or spaces in its naming.'), null, $returnurl);
        }

        // The API function is called.
        $dudid = ModUtil::apiFunc('Profile', 'admin', 'create', array(
            'label'          => $filteredlabel,
            'attribute_name' => $attrname,
            'required'       => $required,
            'viewby'         => $viewby,
            'dtype'          => 1,
            'displaytype'    => $displaytype,
            'listoptions'    => $listoptions,
            'note'           => $note,
        ));

        // The return value of the function is checked here
        if ($dudid != false) {
            // Success
            LogUtil::registerStatus($this->__('Done! Created new personal info item.'));
        }

        // This function generated no output
        return System::redirect($returnurl);
    }
コード例 #4
0
ファイル: Admin.php プロジェクト: projectesIF/Sirius
    /**
     * Create a new dynamic user data item.
     * 
     * Parameters passed in the $args array:
     * -------------------------------------
     * string label          The name of the item to be created.
     * string attribute_name The attribute name of the item to be created.
     * string dtype          The DUD type of the item to be created.
     * 
     * @param array $args All parameters passed to this function.
     * 
     * @return boolean|integer dud item ID on success, false on failure
     */
    public function create($args)
    {
        // Argument check
        if ((!isset($args['label']) || empty($args['label'])) ||
                (!isset($args['attribute_name']) || empty($args['attribute_name'])) ||
                (!isset($args['dtype']) || !is_numeric($args['dtype']))) {
            return LogUtil::registerArgsError();
        }

        // Security check
        if (!SecurityUtil::checkPermission('Profile::item', "$args[label]::", ACCESS_ADD)) {
            return LogUtil::registerPermissionError();
        }



        // Clean the label
        $permsep = System::getVar('shorturlsseparator', '-');
        $args['label'] = str_replace($permsep, '', DataUtil::formatPermalink($args['label']));
        $args['label'] = str_replace('-', '', DataUtil::formatPermalink($args['label']));

        // Check if the label or attribute name already exists
        $item = ModUtil::apiFunc('Profile', 'user', 'get', array('proplabel' => $args['label']));
        if ($item) {
            return LogUtil::registerError($this->__("Error! There is already an personal info item with the label '%s'.", DataUtil::formatForDisplay($args['label'])));
        }
        $item = ModUtil::apiFunc('Profile', 'user', 'get', array('propattribute' => $args['attribute_name']));
        if ($item) {
            return LogUtil::registerError($this->__("Error! There is already an personal info item with the attribute name '%s'.", DataUtil::formatForDisplay($args['attribute_name'])));
        }

        // Determine the new weight
        $weightlimits = ModUtil::apiFunc('Profile', 'user', 'getweightlimits');
        $weight = $weightlimits['max'] + 1;

        // a checkbox can't be required
        if ($args['displaytype'] == 2 && $args['required']) {
            $args['required'] = 0;
        }

        // produce the validation array
        $args['listoptions'] = str_replace(Chr(10), '', str_replace(Chr(13), '', $args['listoptions']));
        $validationinfo = array('required' => $args['required'],
            'viewby' => $args['viewby'],
            'displaytype' => $args['displaytype'],
            'listoptions' => $args['listoptions'],
            'note' => $args['note']);

        $obj = array();
        $obj['prop_label'] = $args['label'];
        $obj['prop_attribute_name'] = $args['attribute_name'];
        $obj['prop_dtype'] = $args['dtype'];
        $obj['prop_weight'] = $weight;
        $obj['prop_validation'] = serialize($validationinfo);

        $res = DBUtil::insertObject($obj, 'user_property', 'prop_id');

        // Check for an error with the database
        if (!$res) {
            return LogUtil::registerError($this->__('Error! Could not create new attribute.'));
        }

        // Return the id of the newly created item to the calling process
        return $obj['prop_id'];
    }
コード例 #5
0
ファイル: Controller.php プロジェクト: rmaiwald/Reviews
 /**
  * Create nice permalinks.
  *
  * @param string $name The given object title.
  *
  * @return string processed permalink.
  * @deprecated made obsolete by Doctrine extensions.
  */
 public function formatPermalink($name)
 {
     $name = str_replace(array('?', '?', '?', '?', '?', '?', '?', '.', '?', '"', '/', ':', '?', '?', '?'), array('ae', 'oe', 'ue', 'Ae', 'Oe', 'Ue', 'ss', '', '', '', '-', '-', 'e', 'e', 'a'), $name);
     $name = DataUtil::formatPermalink($name);
     return strtolower($name);
 }
コード例 #6
0
ファイル: User.php プロジェクト: projectesIF/Sirius
    /**
     * create a new News item
     *
     * @param $args['name'] name of the item
     * @param $args['number'] number of the item
     * @return mixed News item ID on success, false on failure
     */
    public function create($args)
    {
        // Argument check
        if (!isset($args['title']) || empty($args['title']) ||
                !isset($args['hometext']) ||
                !isset($args['hometextcontenttype']) ||
                !isset($args['bodytext']) ||
                !isset($args['bodytextcontenttype']) ||
                !isset($args['notes'])) {
            return LogUtil::registerArgsError();
        }

        // evaluates the input action
        $args['action'] = isset($args['action']) ? $args['action'] : null;
        switch ($args['action'])
        {
            case News_Controller_User::ACTION_SUBMIT: // submitted => pending
                $args['published_status'] = self::STATUS_PENDING;
                break;
            case News_Controller_User::ACTION_PUBLISH:
            case News_Controller_User::ACTION_REJECT:
            case News_Controller_User::ACTION_SAVEPENDING:
            case News_Controller_User::ACTION_ARCHIVE:
                $args['published_status'] = $args['action']-2;
                break;
            case News_Controller_User::ACTION_SAVEDRAFT:
            case News_Controller_User::ACTION_SAVEDRAFT_RETURN:
                $args['published_status'] = self::STATUS_DRAFT;
                break;
        }

        // Security check
        if (!SecurityUtil::checkPermission('News::', '::', ACCESS_COMMENT)) {
            return LogUtil::registerPermissionError();

        } elseif (SecurityUtil::checkPermission('News::', '::', ACCESS_ADD)) {
            if (!isset($args['published_status'])) {
                $args['published_status'] = self::STATUS_PUBLISHED;
            }
        } else {
            $args['published_status'] = self::STATUS_PENDING;
        }

        // calculate the format type
        $args['format_type'] = ($args['bodytextcontenttype']%4)*4 + $args['hometextcontenttype']%4;

        // define the lowercase permalink, using the title as slug, if not present
        if (!isset($args['urltitle']) || empty($args['urltitle'])) {
            $args['urltitle'] = strtolower(DataUtil::formatPermalink($args['title']));
        }

        // check the publishing date options
        if ((!isset($args['from']) && !isset($args['to'])) || (isset($args['unlimited']) && !empty($args['unlimited']))) {
            $args['from'] = null;
            $args['to'] = null;
        } elseif (isset($args['from']) && (isset($args['tonolimit']) && !empty($args['tonolimit']))) {
            $args['from'] = DateUtil::formatDatetime($args['from']);
            $args['to'] = null;
        } else {
            $args['from'] = DateUtil::formatDatetime($args['from']);
            $args['to'] = DateUtil::formatDatetime($args['to']);
        }

        // Work out name of story submitter and approver
        $args['approver'] = 0;
        if (!UserUtil::isLoggedIn() && empty($args['contributor'])) {
            $args['contributor'] = System::getVar('anonymous');
        } else {
            $args['contributor'] = UserUtil::getVar('uname');
            if ($args['published_status'] == self::STATUS_PUBLISHED) {
                $args['approver'] = UserUtil::getVar('uid');
            }
        }

        $args['counter']  = 0;
        $args['comments'] = 0;

        if (!($obj = DBUtil::insertObject($args, 'news', 'sid'))) {
            return LogUtil::registerError($this->__('Error! Could not create new article.'));
        }

        // update the from field to the same cr_date if it's null
        if (is_null($args['from'])) {
            $obj = array('sid'  => $obj['sid'], 'from' => $obj['cr_date']);
            if (!DBUtil::updateObject($obj, 'news', '', 'sid')) {
                LogUtil::registerError($this->__('Error! Could not save your changes.'));
            }
        }

        // Return the id of the newly created item to the calling process
        return $args['sid'];
    }
コード例 #7
0
ファイル: Controller.php プロジェクト: rmaiwald/MUBoard
 /**
  * Create nice permalinks.
  */
 public static function formatPermalink($name)
 {
     $name = str_replace(array('ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü', 'ß', '.', '?', '"', '/', ':', 'é', 'è', 'â'), array('ae', 'oe', 'ue', 'Ae', 'Oe', 'Ue', 'ss', '', '', '', '-', '-', 'e', 'e', 'a'), $name);
     $name = DataUtil::formatPermalink($name);
     return strtolower($name);
 }
コード例 #8
0
ファイル: Dud.php プロジェクト: projectesIF/Sirius
    /**
     * Register a dynamic user data field.
     *
     * Parameters passed in the $args array:
     * -------------------------------------
     * string  modname        Responsible module of the new field.
     * string  label          Label for the new account property.
     * string  attribute_name Name of the attribute to use inside the user's data.
     * string  dtype          Dud type to create {normal, mandatory, noneditable}.
     * array   validationinfo Validation info for the new field with the following fields:
     *                   'required'    => {0: no, 1: mandatory}
     *                   'viewby'      => viewable by {0: Everyone, 1: Registered users only, 2: Admins only}
     *                   'displaytype' => {0: text box, 1: textarea, 2: checkbox, 3: radio, 4: select, 5: date, 7: multi checkbox}
     *                   'listoptions' => options for the new field
     *                   'note'        => note to show in edit mode
     *                   and any other required data.
     * 
     * @param array $args All parameters passed to this function.
     * 
     * @return boolean True on success or false on failure.
     */
    public function register($args)
    {
        if (!isset($args['modname']) || empty($args['modname'])
                || !isset($args['label']) || empty($args['label'])
                || !isset($args['attribute_name']) || empty($args['attribute_name'])
                || !isset($args['dtype']) || empty($args['dtype'])
                || !isset($args['displaytype']) || !is_numeric($args['displaytype']) || (int)$args['displaytype'] < 0
                || !isset($args['validationinfo']) || empty($args['validationinfo']) || !is_array($args['validationinfo'])) {
            return LogUtil::registerArgsError();
        }

        // Security check
        if (!SecurityUtil::checkPermission('Profile::item', "$args[label]::", ACCESS_ADD)) {
            return LogUtil::registerPermissionError();
        }

        if (!ModUtil::getIdFromName($args['modname'])) {
            return LogUtil::registerError($this->__f('Error! Could not find the specified module (%s).', DataUtil::formatForDisplay($args['modname'])));
        }

        // parses the DUD type
        $dtypes = array(-1 => 'noneditable', 0 => 'mandatory', 2 => 'normal');
        if (!in_array($args['dtype'], $dtypes)) {
            return LogUtil::registerError($this->__f("Error! Invalid '%s' passed.", 'dtype'));
        }

        // Clean the label
        $permsep = System::getVar('shorturlsseparator', '-');
        $args['label'] = str_replace($permsep, '', DataUtil::formatPermalink($args['label']));
        $args['label'] = str_replace('-', '', DataUtil::formatPermalink($args['label']));

        // Check if the label or attribute name already exists
        $item = ModUtil::apiFunc('Profile', 'user', 'get', array('proplabel' => $args['label']));
        if ($item) {
            return LogUtil::registerError($this->__("Error! There is already an personal info item with the label '%s'.", DataUtil::formatForDisplay($args['label'])));
        }
        $item = ModUtil::apiFunc('Profile', 'user', 'get', array('propattribute' => $args['attribute_name']));
        if ($item) {
            return LogUtil::registerError($this->__("Error! There is already an personal info item with the attribute name '%s'.", DataUtil::formatForDisplay($args['attribute_name'])));
        }

        // Determine the new weight
        $weightlimits = ModUtil::apiFunc('Profile', 'user', 'getweightlimits');
        $weight = $weightlimits['max'] + 1;

        // insert the new field
        $obj = array();
        $obj['prop_label']          = $args['label'];
        $obj['prop_attribute_name'] = $args['attribute_name'];
        $obj['prop_dtype']          = array_search($args['dtype'], $dtypes);
        $obj['prop_modname']        = $args['modname'];
        $obj['prop_weight']         = $weight;
        $obj['prop_validation']     = serialize($args['validationinfo']);

        $obj = DBUtil::insertObject($obj, 'user_property', 'prop_id');

        // Check for an error with the database
        if (!$obj) {
            return LogUtil::registerError($this->__('Error! Could not create the new personal info item.'));
        }

        // Return the id of the newly created item to the calling process
        return $obj['prop_id'];
    }
コード例 #9
0
ファイル: User.php プロジェクト: projectesIF/Sirius
    public function createDoc($args) {
        $documentName = FormUtil::getPassedValue('documentName', isset($args['documentName']) ? $args['documentName'] : null, 'POST');
        $categoryId = FormUtil::getPassedValue('categoryId', isset($args['categoryId']) ? $args['categoryId'] : 0, 'POST');
        $documentFile = FormUtil::getPassedValue('documentFile', isset($args['documentFile']) ? $args['documentFile'] : null, 'FILES');
        $documentLink = FormUtil::getPassedValue('documentLink', isset($args['documentLink']) ? $args['documentLink'] : null, 'POST');
        $version = FormUtil::getPassedValue('version', isset($args['version']) ? $args['version'] : null, 'POST');
        $authorName = FormUtil::getPassedValue('authorName', isset($args['authorName']) ? $args['authorName'] : null, 'POST');
        $description = FormUtil::getPassedValue('description', isset($args['description']) ? $args['description'] : null, 'POST');
        $documentId = FormUtil::getPassedValue('documentId', isset($args['documentId']) ? $args['documentId'] : 0, 'POST'); // in case it is a new version
        // Security check
        if (!SecurityUtil::checkPermission('IWdocmanager::', '::', ACCESS_READ)) {
            return LogUtil::registerPermissionError();
        }

        // Confirm authorisation code
        $this->checkCsrfToken();

        // check if user can access to this category
        $canAccess = ModUtil::func($this->name, 'user', 'canAccessCategory', array('categoryId' => $categoryId,
                    'accessType' => 'add'));
        if (!$canAccess) {
            LogUtil::registerError($this->__('You can not add documents to this category'));
            return System::redirect(ModUtil::url($this->name, 'user', 'viewDocs'));
        }

        $versionFrom = '';
        $filesize = '';

        if ($documentId > 0) {
            // get document
            $document = ModUtil::apiFunc($this->name, 'user', 'getDocument', array('documentId' => $documentId));
            if (!$document) {
                return LogUtil::registerError($this->__('Document not found.'));
            }
            $versionFrom = $document['versionFrom'] . '$' . $documentId . '$';
            // protectionn. Only validated and not versioned documents can be versioned
            if ($document['validated'] == 0 || $document['versioned'] > 0) {
                LogUtil::registerError($this->__('It is not possible to create a version of this document.'));
                return System::redirect(ModUtil::url($this->name, 'user', 'viewDocs', array('categoryId' => $document['categoryId'])));
            }
        }

        if ($documentFile['name'] != '') {
            // check if the document have the correct extension
            $allowedExtensionsText = ModUtil::getVar('IWmain', 'extensions');
            $allowed_extensions = explode('|', $allowedExtensionsText);
            $extension = FileUtil::getExtension($documentFile['name']);
            if (!in_array($extension, $allowed_extensions)) {
                LogUtil::registerError($this->__('The document have not the correct extension.'));
                return System::redirect(ModUtil::url($this->name, 'user', 'viewDocs'));
            }
            $documentLink = '';
            $filesize = $documentFile['size'];
        }

        $documentLink = (substr($documentLink, 0, 4) != 'http' && $documentLink != '') ? 'http://' . $documentLink : $documentLink;

        $created = ModUtil::apiFunc($this->name, 'user', 'createDoc', array('documentName' => $documentName,
                    'categoryId' => $categoryId,
                    'documentLink' => $documentLink,
                    'version' => $version,
                    'authorName' => $authorName,
                    'description' => $description,
                    'fileOriginalName' => DataUtil::formatPermalink(str_replace('.' . $extension, '', $documentFile['name'])) . '.' . $extension, // remove extension before formatPermalink and then at it again
                    'versionFrom' => $versionFrom,
                    'filesize' => $filesize,
                ));

        if (!$created) {
            LogUtil::registerError($this->__('Error: uploading document'));
            return System::redirect(ModUtil::url($this->name, 'user', 'viewDocs'));
        }

        // update the attached file to the server
        if ($documentFile['name'] != '') {
            $folder = $this->getVar('documentsFolder');
            $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
            $update = ModUtil::func('IWmain', 'user', 'updateFile', array('sv' => $sv,
                        'folder' => $folder,
                        'file' => $documentFile,
                        'fileName' => $created . '.' . $extension,
                    ));
            // the function returns the error string if the update fails and and empty string if success
            if ($update['msg'] != '') {
                LogUtil::registerError($update['msg'] . ' ' . $this->__('An error has occurred in the attachment of the file. The document not has been send.'));
            } else {
                // set document name in data base
                ModUtil::apiFunc($this->name, 'user', 'setFileName', array('documentId' => $created,
                    'fileName' => $created . '.' . $extension,
                ));
            }
        }

        // set original document as versioned only if the document is set as validated (ACCESS_ADD permissions)
        if ($documentId > 0) {
            ModUtil::apiFunc($this->name, 'user', 'setAsVersioned', array('documentId' => $documentId,
                'versioned' => $created,
            ));
        }

        // upload the number of documents in category
        ModUtil::apiFunc($this->name, 'user', 'countDocuments', array('categoryId' => $categoryId));

        $returnMsg = $this->__('The document has been uploaded successfuly');

        $returnMsg .= (SecurityUtil::checkPermission('IWdocmanager::', '::', ACCESS_ADD)) ? "." : $this->__(' and it is pending of validation');

        LogUtil::registerStatus($returnMsg);

        // informs via email about the document creation
        if ($this->getVar('notifyMail') != '') {
            // Check if Mailer is active
            $modid = ModUtil::getIdFromName('Mailer');
            $modinfo = ModUtil::getInfo($modid);
            $mailerAvailable = ($modinfo['state'] == 3) ? 1 : 0;
            
            // Send message if it is possible
            if ($mailerAvailable) {
                $subject = $this->__f('A new document has been created by %s', UserUtil::getVar('uname'));
                $body = $this->__f('A new document <strong>%1$s</strong> has been received. It has been created by %2$s. Please check the documents list and proceed to validate it, if necessary.', array($documentName, UserUtil::getVar('uname')));
                
                ModUtil::apiFunc('Mailer', 'user', 'sendmessage', array(
                    'toname' => 'IWdocmanager',
                    'toaddress' => $this->getVar('notifyMail'),
                    'subject' =>$subject,
                    'body' => $body,
                    'html' => 1));
            }
        }

        return System::redirect(ModUtil::url($this->name, 'user', 'viewDocs', array('categoryId' => $categoryId)));
    }
コード例 #10
0
ファイル: Page.php プロジェクト: projectesIF/Sirius
    public function reinsertPage($args)
    {
        $pageData = $args['page'];

        if ($pageData['parentPageId'] > 0) {
            $sourcePageData = $this->getPage(array('id' => $pageData['parentPageId'], 'checkActive' => false, 'includeContent' => false));
            if ($sourcePageData === false) {
                $pageData['parentPageId'] = 0;
            }
        } else {
            $sourcePageData = null;
        }

        $pageData['language'] = ZLanguage::getLanguageCode();

        // what does this mean?
        if ($pageData['parentPageId'] > 0) {
            $pageData['position'] = $this->contentGetLastSubPagePosition($pageData['parentPageId']) + 1;
            $pageData['level'] = ($sourcePageData == null ? 0 : $sourcePageData['level'] + 1);
        } else {
            $pageData['position'] = $this->contentGetLastPagePosition($pageData['parentPageId']) + 1;
            $pageData['parentPageId'] = ($sourcePageData == null ? 0 : $sourcePageData['parentPageId']);
            $pageData['level'] = ($sourcePageData == null ? 0 : $sourcePageData['level']);
        }

        $ok = $this->isUniqueUrlnameByParentID(array('urlname' => $pageData['urlname'], 'parentId' => $pageData['parentPageId']));
        while (!$ok) {
            $pageData['urlname'] = DataUtil::formatPermalink(RandomUtil::getString(12, 12, false, true, true, false, true, false, true));
            $ok = $this->isUniqueUrlnameByParentID(array('urlname' => $pageData['urlname'], 'parentId' => $pageData['parentPageId']));
        }

        $pageData['setLeft'] = -2;
        $pageData['setRight'] = -1;

        $this->setInitialPageState($pageData);

        $newPage = DBUtil::insertObject($pageData, 'content_page', true);
        Content_Util::contentMainEditExpandSet($pageData['parentPageId'], true);

        $ok = $this->insertPage(array('pageId' => $pageData['id'], 'position' => $pageData['position'], 'parentPageId' => $pageData['parentPageId']));
        if ($ok === false) {
            return false;
        }

        Content_Util::clearCache();
        return array('id' => $pageData['id'], 'urlname' => $pageData['urlname']);
    }
コード例 #11
0
/**
 * Format permalink.
 *
 * Example:
 *   {$MyString|formatpermalink}
 *
 * @param string $string         The contents to transform.
 *
 * @return string The modified output.
 */
function smarty_modifier_formatpermalink($string)
{
    return DataUtil::formatPermalink($string);
}