• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP K2Model类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: report

 function report()
 {
     $model = K2Model::getInstance('User', 'K2Model');
     $model->setState('id', JRequest::getInt('id'));
     $model->reportSpammer();
     $this->setRedirect('index.php?option=com_k2&view=users');
 }
开发者ID:educakanchay,项目名称:educa,代码行数:7,代码来源:user.php


示例2: getInput

 protected function getInput()
 {
     $document = JFactory::getDocument();
     $document->addScriptDeclaration('var K2BasePath = "' . JURI::root(true) . '";');
     $document->addScript(JURI::root(true) . '/plugins/josetta_ext/k2item/fields/k2extrafields.js');
     K2Model::addIncludePath(JPATH_SITE . '/components/com_k2/models');
     JLoader::register('K2HelperUtilities', JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'helpers' . DS . 'utilities.php');
     $model = K2Model::getInstance('Item', 'K2Model');
     $extraFields = $model->getItemExtraFields($this->value);
     $html = '<div id="extraFieldsContainer">';
     if (count($extraFields)) {
         $html .= '<table class="admintable" id="extraFields">';
         foreach ($extraFields as $extraField) {
             $html .= '<tr>
             <td align="right" class="key">' . $extraField->name . '</td>
             <td>' . $extraField->element . '</td>
             </tr>';
         }
         $html .= '</table>';
     } else {
         $html .= '<span class="k2Note"> ' . JText::_('K2_PLEASE_SELECT_A_CATEGORY_FIRST_TO_RETRIEVE_ITS_RELATED_EXTRA_FIELDS') . ' </span>';
     }
     $html .= '</div>';
     return $html;
 }
开发者ID:Roma48,项目名称:abazherka_old,代码行数:25,代码来源:k2extrafields.php


示例3: onJosettaLoadItem

 public function onJosettaLoadItem($context, $id = '')
 {
     if (!empty($context) && $context != $this->_context || empty($id)) {
         return null;
     }
     $item = parent::onJosettaLoadItem($context, $id);
     // Merge introtext and fulltext
     $item->articletext = trim($item->fulltext) != '' ? $item->introtext . "<hr id=\"system-readmore\" />" . $item->fulltext : $item->introtext;
     // Get tags
     K2Model::addIncludePath(JPATH_SITE . '/components/com_k2/models');
     JLoader::register('K2HelperUtilities', JPATH_SITE . '/components/com_k2/helpers/utilities.php');
     $model = K2Model::getInstance('Item', 'K2Model');
     $tags = $model->getItemTags($item->id);
     $tmp = array();
     foreach ($tags as $tag) {
         $tmp[] = $tag->name;
     }
     $item->tags = implode(', ', $tmp);
     // Get extra fields
     $extraFields = $model->getItemExtraFields($item->extra_fields);
     $html = '';
     if (count($extraFields)) {
         $html .= '<ul>';
         foreach ($extraFields as $key => $extraField) {
             $html .= '<li class="type' . ucfirst($extraField->type) . ' group' . $extraField->group . '">
             <span class="itemExtraFieldsLabel">' . $extraField->name . ':</span>
             <span class="itemExtraFieldsValue">' . $extraField->value . '</span>
         </li>';
         }
         $html .= '</ul>';
     }
     $item->extra_fields = $html;
     // Return the item
     return $item;
 }
开发者ID:Roma48,项目名称:abazherka_old,代码行数:35,代码来源:k2item.php


示例4: getAvatar

 public static function getAvatar($userID, $email = NULL, $width = 50)
 {
     jimport('joomla.filesystem.folder');
     jimport('joomla.application.component.model');
     $mainframe = JFactory::getApplication();
     $params = K2HelperUtilities::getParams('com_k2');
     if (K2_CB && $userID != 'alias') {
         $cbUser = CBuser::getInstance((int) $userID);
         if (is_object($cbUser)) {
             $avatar = $cbUser->getField('avatar', null, 'csv', 'none', 'profile');
             return $avatar;
         }
     }
     /*
     // JomSocial Avatar integration
     if(JFolder::exists(JPATH_SITE.DS.'components'.DS.'com_community') && $userID>0){
     $userInfo = &CFactory::getUser($userID);
     return $userInfo->getThumbAvatar();
     }
     */
     // Check for placeholder overrides
     if (JFile::exists(JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'images' . DS . 'placeholder' . DS . 'user.png')) {
         $avatarPath = 'templates/' . $mainframe->getTemplate() . '/images/placeholder/user.png';
     } else {
         $avatarPath = 'components/com_k2/images/placeholder/user.png';
     }
     // Continue with default K2 avatar determination
     if ($userID == 'alias') {
         $avatar = JURI::root(true) . '/' . $avatarPath;
     } else {
         if ($userID == 0) {
             if ($params->get('gravatar') && !is_null($email)) {
                 $avatar = 'http://www.gravatar.com/avatar/' . md5($email) . '?s=' . $width . '&amp;default=' . urlencode(JURI::root() . $avatarPath);
             } else {
                 $avatar = JURI::root(true) . '/' . $avatarPath;
             }
         } else {
             if (is_numeric($userID) && $userID > 0) {
                 K2Model::addIncludePath(JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'models');
                 $model = K2Model::getInstance('Item', 'K2Model');
                 $profile = $model->getUserProfile($userID);
                 $avatar = is_null($profile) ? '' : $profile->image;
                 if (empty($avatar)) {
                     if ($params->get('gravatar') && !is_null($email)) {
                         $avatar = 'http://www.gravatar.com/avatar/' . md5($email) . '?s=' . $width . '&amp;default=' . urlencode(JURI::root() . $avatarPath);
                     } else {
                         $avatar = JURI::root(true) . '/' . $avatarPath;
                     }
                 } else {
                     $avatar = JURI::root(true) . '/media/k2/users/' . $avatar;
                 }
             }
         }
     }
     if (!$params->get('userImageDefault') && $avatar == JURI::root(true) . '/' . $avatarPath) {
         $avatar = '';
     }
     return $avatar;
 }
开发者ID:Gskflute,项目名称:joomla25,代码行数:59,代码来源:utilities.php


示例5: display

    function display($tpl = null)
    {
        JRequest::setVar('hidemainmenu', 1);
        $model = $this->getModel();
        $extraField = $model->getData();
        if (!$extraField->id) {
            $extraField->published = 1;
        }
        $this->assignRef('row', $extraField);
        $lists = array();
        $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $extraField->published);
        $groups[] = JHTML::_('select.option', 0, JText::_('K2_CREATE_NEW_GROUP'));
        $extraFieldModel = K2Model::getInstance('ExtraFields', 'K2Model');
        $uniqueGroups = $extraFieldModel->getGroups(true);
        foreach ($uniqueGroups as $group) {
            $groups[] = JHTML::_('select.option', $group->id, $group->name);
        }
        $lists['group'] = JHTML::_('select.genericlist', $groups, 'groups', '', 'value', 'text', $extraField->group);
        $typeOptions[] = JHTML::_('select.option', 0, JText::_('K2_SELECT_TYPE'));
        $typeOptions[] = JHTML::_('select.option', 'textfield', JText::_('K2_TEXT_FIELD'));
        $typeOptions[] = JHTML::_('select.option', 'textarea', JText::_('K2_TEXTAREA'));
        $typeOptions[] = JHTML::_('select.option', 'select', JText::_('K2_DROPDOWN_SELECTION'));
        $typeOptions[] = JHTML::_('select.option', 'multipleSelect', JText::_('K2_MULTISELECT_LIST'));
        $typeOptions[] = JHTML::_('select.option', 'radio', JText::_('K2_RADIO_BUTTONS'));
        $typeOptions[] = JHTML::_('select.option', 'link', JText::_('K2_LINK'));
        $typeOptions[] = JHTML::_('select.option', 'csv', JText::_('K2_CSV_DATA'));
        $typeOptions[] = JHTML::_('select.option', 'labels', JText::_('K2_SEARCHABLE_LABELS'));
        $typeOptions[] = JHTML::_('select.option', 'date', JText::_('K2_DATE'));
        $lists['type'] = JHTML::_('select.genericlist', $typeOptions, 'type', '', 'value', 'text', $extraField->type);
        $this->assignRef('lists', $lists);
        JRequest::getInt('cid') ? $title = JText::_('K2_EDIT_EXTRA_FIELD') : ($title = JText::_('K2_ADD_EXTRA_FIELD'));
        JToolBarHelper::title($title, 'k2.png');
        JToolBarHelper::save();
        JToolBarHelper::apply();
        JToolBarHelper::cancel();
        JHTML::_('behavior.calendar');
        $document = JFactory::getDocument();
        $document->addScriptDeclaration('
		var K2Language = [
		"' . JText::_('K2_REMOVE', true) . '", 
		"' . JText::_('K2_OPTIONAL', true) . '",
		"' . JText::_('K2_COMMA_SEPARATED_VALUES', true) . '",
		"' . JText::_('K2_USE_EDITOR', true) . '",
		"' . JText::_('K2_ALL_SETTINGS_ABOVE_ARE_OPTIONAL', true) . '",
		"' . JText::_('K2_ADD_AN_OPTION', true) . '",
		"' . JText::_('K2_LINK_TEXT', true) . '",
		"' . JText::_('K2_URL', true) . '",
		"' . JText::_('K2_OPEN_IN', true) . '",
		"' . JText::_('K2_SAME_WINDOW', true) . '",
		"' . JText::_('K2_NEW_WINDOW', true) . '",
		"' . JText::_('K2_CLASSIC_JAVASCRIPT_POPUP', true) . '",
		"' . JText::_('K2_LIGHTBOX_POPUP', true) . '",
		"' . JText::_('K2_RESET_VALUE', true) . '",
		"' . JText::_('K2_CALENDAR', true) . '",
		"' . JText::_('K2_PLEASE_SELECT_A_FIELD_TYPE_FROM_THE_LIST_ABOVE', true) . '",
		];');
        parent::display($tpl);
    }
开发者ID:GitIPFire,项目名称:Homeworks,代码行数:58,代码来源:view.html.php


示例6: getInstance

 /**
  * Gets an item instance.
  *
  * @param integer $id	The id of the item to get.
  *
  * @return K2Tag The tag object.
  */
 public static function getInstance($id)
 {
     if (empty(self::$instances[$id])) {
         K2Model::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/models');
         $model = K2Model::getInstance('Comments', 'K2Model');
         $model->setState('id', $id);
         $item = $model->getRow();
         self::$instances[$id] = $item;
     }
     return self::$instances[$id];
 }
开发者ID:Naldo100,项目名称:k2-v3-dev-build,代码行数:18,代码来源:comments.php


示例7: getOptions

 protected function getOptions()
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_k2/models/categories.php';
     $categoriesModel = K2Model::getInstance('Categories', 'K2Model');
     $categories = $categoriesModel->categoriesTree(NULL, true, false);
     $options = array();
     $options[] = JHtml::_('select.option', 0, 'All');
     foreach ($categories as $ca) {
         $options[] = JHtml::_('select.option', $ca->value, $ca->text);
     }
     return $options;
 }
开发者ID:educakanchay,项目名称:educared,代码行数:12,代码来源:sjk2categories.php


示例8: getFields

 public function getFields()
 {
     $fields = array();
     if ($this->id) {
         K2Model::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/models');
         $model = K2Model::getInstance('ExtraFields', 'K2Model');
         $model->setState('group', $this->id);
         $model->setState('sorting', 'ordering');
         $fields = $model->getRows();
     }
     return $fields;
 }
开发者ID:Naldo100,项目名称:k2-v3-dev-build,代码行数:12,代码来源:extrafieldsgroups.php


示例9: getList

 public static function getList(&$params)
 {
     $mainframe = JFactory::getApplication();
     if ($params->get('catfilter')) {
         $cid = $params->get('category_id', NULL);
     } else {
         $itemListModel = K2Model::getInstance('Itemlist', 'K2Model');
         $cid = $itemListModel->getCategoryTree($category = 0);
     }
     $items = self::getItems($cid, $params);
     return $items;
 }
开发者ID:educakanchay,项目名称:educared,代码行数:12,代码来源:helper.php


示例10: _findItem

 public static function _findItem($catid)
 {
     $component = JComponentHelper::getComponent('com_jak2filter');
     $application = JFactory::getApplication();
     $menus = $application->getMenu('site', array());
     if (K2_JVERSION != '15') {
         $items = $menus->getItems('component_id', $component->id);
     } else {
         $items = $menus->getItems('componentid', $component->id);
     }
     $match = null;
     if (count($items)) {
         foreach ($items as $item) {
             if ($catid) {
                 if (@$item->query['view'] == 'itemlist' && @$item->query['category_id'] == $catid) {
                     $match = $item;
                     break;
                 }
             } else {
                 if (@$item->query['view'] == 'itemlist' && !isset($item->query['category_id'])) {
                     $match = $item;
                     break;
                 }
             }
         }
     }
     if (is_null($match)) {
         // Try to detect any parent category menu item....
         if (is_null(self::$tree)) {
             include_once JPATH_ADMINISTRATOR . '/components/com_k2/models/model.php';
             K2Model::addIncludePath(JPATH_SITE . '/components/com_k2/models');
             $model = K2Model::getInstance('Itemlist', 'K2Model');
             self::$model = $model;
             self::$tree = $model->getCategoriesTree();
         }
         $parents = self::$model->getTreePath(self::$tree, $catid);
         if (is_array($parents)) {
             foreach ($parents as $categoryID) {
                 if ($categoryID != $catid) {
                     $match = JAK2FilterHelperRoute::_findItem($categoryID);
                     if (!is_null($match)) {
                         break;
                     }
                 }
             }
         }
         if (is_null($match) && !is_null(self::$anyK2Link)) {
             $match = self::$anyK2Link;
         }
     }
     return $match;
 }
开发者ID:jamielaff,项目名称:als_resourcing,代码行数:52,代码来源:route.php


示例11: display

 public function display($cachable = false, $urlparams = array())
 {
     $model = $this->getModel('itemlist');
     $document = JFactory::getDocument();
     $viewType = $document->getType();
     $view = $this->getView('item', $viewType);
     $view->setModel($model);
     JRequest::setVar('view', 'item');
     $user = JFactory::getUser();
     if ($user->guest) {
         $cache = true;
     } else {
         $cache = true;
         JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
         $row = JTable::getInstance('K2Item', 'Table');
         $row->load(JRequest::getInt('id'));
         if (K2HelperPermissions::canEditItem($row->created_by, $row->catid)) {
             $cache = false;
         }
         $params = K2HelperUtilities::getParams('com_k2');
         if ($row->created_by == $user->id && $params->get('inlineCommentsModeration')) {
             $cache = false;
         }
         if ($row->access > 0) {
             $cache = false;
         }
         $category = JTable::getInstance('K2Category', 'Table');
         $category->load($row->catid);
         if ($category->access > 0) {
             $cache = false;
         }
         if ($params->get('comments') && $document->getType() == 'html') {
             $itemListModel = K2Model::getInstance('Itemlist', 'K2Model');
             $profile = $itemListModel->getUserProfile($user->id);
             $script = "\n\$K2(document).ready(function() {\n\$K2('#userName').val('" . $view->escape($user->name) . "').attr('disabled', 'disabled');\n\$K2('#commentEmail').val('" . $user->email . "').attr('disabled', 'disabled');";
             if (is_object($profile) && $profile->url) {
                 $script .= " \$K2('#commentURL').val('" . htmlspecialchars($profile->url, ENT_QUOTES, 'UTF-8') . "').attr('disabled', 'disabled');";
             }
             $script .= " });";
             $document->addScriptDeclaration($script);
         }
     }
     if (K2_JVERSION != '15') {
         $urlparams['id'] = 'INT';
         $urlparams['print'] = 'INT';
         $urlparams['lang'] = 'CMD';
         $urlparams['Itemid'] = 'INT';
     }
     parent::display($cache, $urlparams);
 }
开发者ID:educakanchay,项目名称:educa,代码行数:50,代码来源:item.php


示例12: getGroups

 public static function getGroups($scope = 'item')
 {
     if (!isset(self::$groups[$scope])) {
         K2Model::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/models');
         $model = K2Model::getInstance('ExtraFieldsGroups', 'K2Model');
         $model->setState('scope', $scope);
         $model->setState('sorting', 'name');
         $rows = $model->getRows();
         self::$groups[$scope] = array();
         foreach ($rows as $row) {
             self::$groups[$scope][$row->id] = $row;
         }
     }
     return self::$groups[$scope];
 }
开发者ID:Naldo100,项目名称:k2-v3-dev-build,代码行数:15,代码来源:extrafields.php


示例13: deleteOrphans

 public function deleteOrphans()
 {
     // Check for token
     JSession::checkToken() or K2Response::throwError(JText::_('JINVALID_TOKEN'));
     // Check permissions
     $user = JFactory::getUser();
     if (!$user->authorise('k2.tags.manage', 'com_k2')) {
         K2Response::throwError(JText::_('K2_YOU_ARE_NOT_AUTHORIZED_TO_PERFORM_THIS_OPERATION'));
     }
     // Get model
     $model = K2Model::getInstance('Tags');
     $model->deleteOrphans();
     $application = JFactory::getApplication();
     $application->enqueueMessage(JText::_('K2_DELETE_COMPLETED'));
     echo json_encode(K2Response::render());
     return $this;
 }
开发者ID:Naldo100,项目名称:k2-v3-dev-build,代码行数:17,代码来源:tags.json.php


示例14: display

 function display($tpl = null)
 {
     JHTML::_('behavior.tooltip');
     JRequest::setVar('hidemainmenu', 1);
     $model = $this->getModel();
     $userGroup = $model->getData();
     if (K2_JVERSION == '15') {
         JFilterOutput::objectHTMLSafe($userGroup);
     } else {
         JFilterOutput::objectHTMLSafe($userGroup, ENT_QUOTES, 'permissions');
     }
     $this->assignRef('row', $userGroup);
     if (K2_JVERSION == '15') {
         $form = new JParameter('', JPATH_COMPONENT . DS . 'models' . DS . 'usergroup.xml');
         $form->loadINI($userGroup->permissions);
         $appliedCategories = $form->get('categories');
         $inheritance = $form->get('inheritance');
     } else {
         jimport('joomla.form.form');
         $form = JForm::getInstance('permissions', JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'usergroup.xml');
         $values = array('params' => json_decode($userGroup->permissions));
         $form->bind($values);
         $inheritance = isset($values['params']->inheritance) ? $values['params']->inheritance : 0;
         $appliedCategories = isset($values['params']->categories) ? $values['params']->categories : '';
     }
     $this->assignRef('form', $form);
     $this->assignRef('categories', $appliedCategories);
     $lists = array();
     require_once JPATH_ADMINISTRATOR . '/components/com_k2/models/categories.php';
     $categoriesModel = K2Model::getInstance('Categories', 'K2Model');
     $categories = $categoriesModel->categoriesTree(NULL, true);
     $categories_options = @array_merge($categories_option, $categories);
     $lists['categories'] = JHTML::_('select.genericlist', $categories, 'params[categories][]', 'multiple="multiple" size="15"', 'value', 'text', $appliedCategories);
     $lists['inheritance'] = JHTML::_('select.booleanlist', 'params[inheritance]', NULL, $inheritance);
     $this->assignRef('lists', $lists);
     JRequest::getInt('cid') ? $title = JText::_('K2_EDIT_USER_GROUP') : ($title = JText::_('K2_ADD_USER_GROUP'));
     JToolBarHelper::title($title, 'k2.png');
     JToolBarHelper::save();
     JToolBarHelper::apply();
     JToolBarHelper::cancel();
     parent::display($tpl);
 }
开发者ID:emavro,项目名称:k2,代码行数:42,代码来源:view.html.php


示例15: report

 public function report()
 {
     // Check for token
     JSession::checkToken() or K2Response::throwError(JText::_('JINVALID_TOKEN'));
     // Get application
     $application = JFactory::getApplication();
     // Get input
     $id = $application->input->get('id', 0, 'int');
     // Get model
     $model = K2Model::getInstance('Users');
     $model->setState('id', $id);
     $model->report();
     if (!$model->report()) {
         K2Response::throwError($model->getError());
     }
     // Response
     echo json_encode(K2Response::render());
     // Return
     return $this;
 }
开发者ID:Naldo100,项目名称:k2-v3-dev-build,代码行数:20,代码来源:users.json.php


示例16: getTopCommenters

 public static function getTopCommenters($params)
 {
     $model = K2Model::getInstance('Users');
     $rows = $model->getTopCommenters();
     $commenters = array();
     foreach ($rows as $row) {
         if ($row->comments > 0) {
             $commenter = K2Users::getInstance($row->userId);
             $commenter->comments = $row->comments;
             $commenter->displayName = $params->get('commenterNameOrUsername', 1) == 2 ? $commenter->username : $commenter->name;
             if ($params->get('commenterLatestComment')) {
                 $model = K2Model::getInstance('Comments');
                 $model->setState('userId', $commenter->id);
                 $model->setState('state', 1);
                 $model->setState('limit', 1);
                 $model->setState('sorting', 'id.reverse');
                 $comments = $model->getRows();
                 $commenter->comment = $comments[0];
             }
             $commenters[] = $commenter;
         }
     }
     return $commenters;
 }
开发者ID:Naldo100,项目名称:k2-v3-dev-build,代码行数:24,代码来源:helper.php


示例17: items

 private function items($id)
 {
     $this->response->status = 'Processing Items';
     $step = 10;
     $session = JFactory::getSession();
     $db = JFactory::getDbo();
     if ($id == 0) {
         $query = $db->getQuery(true);
         $query->select('COUNT(*)')->from($db->quoteName('#__k2_v2_items'));
         $db->setQuery($query);
         $total = $db->loadResult();
         $session->set('k2.upgrade.items.total', $total);
         $session->set('k2.upgrade.items.processed', 0);
     }
     $query = $db->getQuery(true);
     $query->select('*')->from($db->quoteName('#__k2_v2_items'))->where($db->quoteName('id') . ' > ' . $id)->order($db->quoteName('id'));
     $db->setQuery($query, 0, $step);
     $items = $db->loadObjectList();
     foreach ($items as $item) {
         $query = $db->getQuery(true);
         $query->select($db->quoteName('id'))->from($db->quoteName('#__k2_items'))->where($db->quoteName('alias') . ' = ' . $db->quote($item->alias));
         $db->setQuery($query);
         if ($db->loadResult()) {
             $item->alias .= '-' . uniqid();
         }
         $data = array();
         $data['id'] = '';
         $data['title'] = $item->title;
         $data['alias'] = $item->alias;
         $data['state'] = $item->trash ? -1 : $item->published;
         $data['featured'] = $item->featured;
         $data['access'] = $item->access;
         $data['catid'] = $item->catid;
         if ($data['catid'] == 1) {
             $data['catid'] = 99999;
         }
         $data['introtext'] = $item->introtext;
         $data['fulltext'] = $item->fulltext;
         $data['ordering'] = $item->ordering;
         $data['featured_ordering'] = $item->featured_ordering;
         $data['created'] = $item->created;
         $data['created_by'] = $item->created_by;
         $data['created_by_alias'] = $item->created_by_alias;
         $data['modified'] = $item->modified;
         $data['modified_by'] = $item->modified_by ? $item->modified_by : $item->created_by;
         $data['publish_up'] = $item->publish_up;
         $data['publish_down'] = $item->publish_down;
         $data['metadata'] = array();
         $data['metadata']['description'] = $item->metadesc;
         $data['metadata']['keywords'] = $item->metakey;
         $data['metadata']['robots'] = '';
         $data['metadata']['author'] = '';
         $metadata = new JRegistry($item->metadata);
         $metadata = $metadata->toArray();
         foreach ($metadata as $key => $value) {
             if ($key == 'robots' || $key == 'author') {
                 $data['metadata'][$key] = $value;
             }
         }
         $data['language'] = $item->language;
         $model = K2Model::getInstance('Items');
         $model->setState('data', $data);
         if (!$model->save()) {
             $this->response->errors[] = $model->getError();
             $this->response->failed = 1;
             return;
         }
         $lastInsertedId = $model->getState('id');
         $image = new stdClass();
         $image->caption = $item->image_caption;
         $image->credits = $item->image_credits;
         $image->flag = JFile::exists(JPATH_SITE . '/media/k2/items/cache/' . md5('Image' . $item->id) . '_Generic.jpg') ? 1 : 0;
         $image = json_encode($image);
         $media = array();
         $mediaEntry = new stdClass();
         $mediaEntry->url = '';
         $mediaEntry->provider = '';
         $mediaEntry->id = '';
         $mediaEntry->embed = '';
         $mediaEntry->caption = $item->video_caption;
         $mediaEntry->credits = $item->video_credits;
         $mediaEntry->upload = '';
         if (!empty($item->video)) {
             if (substr($item->video, 0, 1) !== '{') {
                 $mediaEntry->embed = $item->video;
             } else {
                 if (strpos($item->video, 'remote}')) {
                     preg_match("#}(.*?){/#s", $item->video, $matches);
                     if (substr($matches[1], 0, 4) != 'http') {
                         $mediaEntry->upload = basename($matches[1]);
                         if (JFile::exists(JPATH_SITE . '/media/k2/videos/' . $mediaEntry->upload)) {
                             if (!JFolder::exists(JPATH_SITE . '/media/k2/media')) {
                                 JFolder::create(JPATH_SITE . '/media/k2/media');
                             }
                             if (!JFolder::exists(JPATH_SITE . '/media/k2/media/' . $item->id)) {
                                 JFolder::create(JPATH_SITE . '/media/k2/media/' . $item->id);
                             }
                             JFile::move(JPATH_SITE . '/media/k2/videos/' . $mediaEntry->upload, JPATH_SITE . '/media/k2/media/' . $item->id . '/' . $mediaEntry->upload);
                         }
                     } else {
//.........这里部分代码省略.........
开发者ID:Naldo100,项目名称:k2-v3-dev-build,代码行数:101,代码来源:migrator.json.php


示例18: remove

 function remove()
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $mainframe = JFactory::getApplication();
     $params = JComponentHelper::getParams('com_k2');
     $itemModel = K2Model::getInstance('Item', 'K2Model');
     $db = JFactory::getDBO();
     $cid = JRequest::getVar('cid');
     JPluginHelper::importPlugin('finder');
     $dispatcher = JDispatcher::getInstance();
     foreach ($cid as $id) {
         $row = JTable::getInstance('K2Item', 'Table');
         $row->load($id);
         $row->id = (int) $row->id;
         //Delete images
         if (JFile::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'src' . DS . md5("Image" . $row->id) . '.jpg')) {
             JFile::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'src' . DS . md5("Image" . $row->id) . '.jpg');
         }
         if (JFile::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_XS.jpg')) {
             JFile::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_XS.jpg');
         }
         if (JFile::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_S.jpg')) {
             JFile::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_S.jpg');
         }
         if (JFile::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_M.jpg')) {
             JFile::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_M.jpg');
         }
         if (JFile::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_L.jpg')) {
             JFile::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_L.jpg');
         }
         if (JFile::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_XL.jpg')) {
             JFile::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_XL.jpg');
         }
         if (JFile::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_Generic.jpg')) {
             JFile::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_Generic.jpg');
         }
         //Delete gallery
         if (JFolder::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'galleries' . DS . $row->id)) {
             JFolder::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'galleries' . DS . $row->id);
         }
         //Delete video
         preg_match_all("#^{(.*?)}(.*?){#", $row->video, $matches, PREG_PATTERN_ORDER);
         $videotype = $matches[1][0];
         $videofile = $matches[2][0];
         $videoExtensions = array('flv', 'mp4', 'ogv', 'webm', 'f4v', 'm4v', '3gp', '3g2', 'mov', 'mpeg', 'mpg', 'avi', 'wmv', 'divx', 'swf');
         $audioExtensions = array('mp3', 'aac', 'mp4', 'ogg', 'wma');
         if (in_array($videotype, $videoExtensions) || in_array($videotype, $audioExtensions)) {
             if (JFile::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'videos' . DS . $videofile . '.' . $videotype)) {
                 JFile::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'videos' . DS . $videofile . '.' . $videotype);
             }
             if (JFile::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'audio' . DS . $videofile . '.' . $videotype)) {
                 JFile::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'audio' . DS . $videofile . '.' . $videotype);
             }
         }
         //Delete attachments
         $path = $params->get('attachmentsFolder', NULL);
         if (is_null($path)) {
             $savepath = JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'attachments';
         } else {
             $savepath = $path;
         }
         $attachments = $itemModel->getAttachments($row->id);
         foreach ($attachments as $attachment) {
             if (JFile::exists($savepath . DS . $attachment->filename)) {
                 JFile::delete($savepath . DS . $attachment->filename);
             }
         }
         $query = "DELETE FROM #__k2_attachments WHERE itemID={$row->id}";
         $db->setQuery($query);
         $db->query();
         //Delete tags
         $query = "DELETE FROM #__k2_tags_xref WHERE itemID={$row->id}";
         $db->setQuery($query);
         $db->query();
         //Delete comments
         $query = "DELETE FROM #__k2_comments WHERE itemID={$row->id}";
         $db->setQuery($query);
         $db->query();
         $row->delete($id);
         $dispatcher->trigger('onFinderAfterDelete', array('com_k2.item', $row));
     }
     $cache = JFactory::getCache('com_k2');
     $cache->clean();
     $mainframe->enqueueMessage(JText::_('K2_DELETE_COMPLETED'));
     $mainframe->redirect('index.php?option=com_k2&view=items');
 }
开发者ID:grchis,项目名称:Site-Auto,代码行数:87,代码来源:items.php


示例19: reportSpammer

    function reportSpammer()
    {
        $mainframe = JFactory::getApplication();
        $user = JFactory::getUser();
        $format = JRequest::getVar('format');
        $errors = array();
        if (K2_JVERSION != '15')
        {
            if (!$user->authorise('core.admin', 'com_k2'))
            {
                $format == 'raw' ? die(JText::_('K2_ALERTNOTAUTH')) : JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
            }
        }
        else
        {
            if ($user->gid < 25)
            {
                $format == 'raw' ? die(JText::_('K2_ALERTNOTAUTH')) : JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
            }
        }
        K2Model::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'models');
        $model = K2Model::getInstance('User', 'K2Model');
        $model->setState('id', JRequest::getInt('id'));
        $model->reportSpammer();
        if ($format == 'raw')
        {
            $response = '';
            $messages = $mainframe->getMessageQueue();
            foreach ($messages as $message)
            {
                $response .= $message['message']."\n";
            }
            die($response);

        }
        $this->setRedirect('index.php?option=com_k2&view=comments&tmpl=component');
    }
开发者ID:GitIPFire,项目名称:Homeworks,代码行数:37,代码来源:comments.php


示例20: move

 function move()
 {
     $mainframe = JFactory::getApplication();
     JTable::addIncludePath(JPATH_COMPONENT . DS . 'tables');
     $cid = JRequest::getVar('cid');
     foreach ($cid as $id) {
         $row = JTable::getInstance('K2Item', 'Table');
         $row->load($id);
         $rows[] = $row;
     }
     $categoriesModel = K2Model::getInstance('Categories', 'K2Model');
     $categories = $categoriesModel->categoriesTree(null, true, false);
     $lists['categories'] = JHTML::_('select.genericlist', $categories, 'category', 'class="inputbox" size="8"', 'value', 'text');
     $this->assignRef('rows', $rows);
     $this->assignRef('lists', $lists);
     JToolBarHelper::title(JText::_('K2_MOVE_ITEMS'), 'k2.png');
     JToolBarHelper::custom('saveMove', 'save.png', 'save_f2.png', 'K2_SAVE', false);
     JToolBarHelper::cancel();
     parent::display();
 }
开发者ID:Roma48,项目名称:abazherka_old,代码行数:20,代码来源:view.html.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP K2View类代码示例发布时间:2022-05-23
下一篇:
PHP K2HelperUtilities类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap